Java CXF 代码生成 maven 插件不起作用 OpenJDK 11
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/52857820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CXF codegen maven plugin doesn't work OpenJDK 11
提问by Nico
I have been working with JDK 9 & 10 and CXF codegen plugin 3.2.5 and 3.2.6 with no problems but, today I'm trying to update my codebase from Oracle JDK 10 to OpenJDK 11 build 28, but I'm always getting the same error:
我一直在使用 JDK 9 和 10 以及 CXF 代码生成插件 3.2.5 和 3.2.6 没有问题,但是,今天我试图将我的代码库从 Oracle JDK 10 更新到 OpenJDK 11 build 28,但我总是得到同样的错误:
[INFO] Error occurred during initialization of boot layer
[INFO] java.lang.module.FindException: Module java.xml.ws not found
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.747 s
[INFO] Finished at: 2018-10-17T16:38:38+02:00
[INFO] Final Memory: 17M/60M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.2.6:wsdl2java (cerberus-wsdl) on project cerberus:
[ERROR] Exit code: 1
[ERROR] Command line was: /opt/prod_jdk/bin/java --add-modules java.activation,java.xml.bind,java.xml.ws --add-exports=java.xml.bind/com.sun.xml.internal.bind.v2.runtime=ALL-UNNAMED --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED --add-exports=java.xml/com.sun.org.apache.xerces.internal.impl.xs=ALL-UNNAMED --add-exports=java.xml.bind/com.sun.xml.internal.bind.marshaller=ALL-UNNAMED --add-opens java.xml.ws/javax.xml.ws.wsaddressing=ALL-UNNAMED --add-opens java.base/java.security=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED -jar /tmp/cxf-tmp-2828938832312113909/cxf-codegen12095310072621993552.jar /tmp/cxf-tmp-2828938832312113909/cxf-w2j12256414556760820901args
this is my pom.xml that use CXF codegen plugin:
这是我使用 CXF 代码生成插件的 pom.xml:
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.6</version>
<configuration>
<fork>once</fork>
</configuration>
<dependencies>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-rt</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
<executions>...</executions>
<plugin>
Am I missing something? As far as I know this should work the same way that in JDK 9 and 10. There is an issue https://issues.apache.org/jira/browse/CXF-7741that talk about JDK 11 compatibility, but again this is for CXF framework not for the plugin (I think).
我错过了什么吗?据我所知,这应该与 JDK 9 和 10 中的工作方式相同。有一个问题https://issues.apache.org/jira/browse/CXF-7741谈论 JDK 11 兼容性,但这又是对于 CXF 框架而不是插件(我认为)。
采纳答案by Initial-B
This issue will be resolved in cxf 3.3.0 (https://issues.apache.org/jira/browse/CXF-7852)
此问题将在 cxf 3.3.0 ( https://issues.apache.org/jira/browse/CXF-7852) 中解决
For now, you can run mvn installin the mvn-plugins directory of https://github.com/apache/cxfto build the plugins, and set version in pom to 3.3.0-SNAPSHOT
目前可以在https://github.com/apache/cxf的 mvn-plugins 目录下运行mvn install来构建插件,并将 pom 中的 version 设置为 3.3.0-SNAPSHOT
Edit: Plugin is in the apache snapshots repo, so probably better to get it from there:
编辑:插件在 apache 快照存储库中,所以从那里获取它可能更好:
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Maven Plugin Snapshots</name>
<url>http://repository.apache.org/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
...
Note (2019-01-28): The plugin is now released, we can add the dependency as usual:
Note (2019-01-28): 插件现已发布,我们可以照常添加依赖:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.0</version>
<type>maven-plugin</type>
</dependency>
回答by Allan Thrane Andersen
I struggled with getting the plugin to work with Java 11 as well. Tried to detail the plugin dependencies to solve the issue:
我也在努力让插件与 Java 11 一起工作。尝试详细说明插件依赖以解决问题:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-xjc-plugin</artifactId>
<version>3.2.3</version>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<!-- Java Architecture for XML Binding (JAXB), Java 11+ support -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb-api.version}</version>
</dependency>
<!-- JavaBeans Activation Framework (JAF), Java 11+ support -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>${jaf-api.version}</version>
</dependency>
<!-- Java API for XML Web Services (JAX-WS), Java 11+ support -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>${jaxws-api.version}</version>
</dependency>
</dependencies>
</plugin>
.. with no luck. The issue went away when I upgraded to version 3.2.3 of the plugin (while waiting for 3.3.0 as described here: https://issues.apache.org/jira/browse/CXF-7852).
.. 没有运气。当我升级到插件的 3.2.3 版时,问题就消失了(在等待 3.3.0 时,如此处所述:https: //issues.apache.org/jira/browse/CXF-7852)。