让cxf-codegen-plugin在Java 9上运行

时间:2018-04-21 18:28:26

标签: java-9 cxf-codegen-plugin

我一直试图让cxf-codegen-plugin在Java 9上运行一些阻力。到目前为止,我已经将java.se.ee添加到运行时模块中,并为maven添加了必要的依赖项。

但是,当我尝试构建我的源时,我收到以下错误:

DefaultValidationEventHandler: [ERROR]: unexpected element (uri:"http://cxf.apache.org/tools/plugin", local:"databinding"). Expected elements are <{}databinding>,<{}frontend> 
 Location:  node: [databinding: null]
apr. 21, 2018 8:23:57 EM org.apache.cxf.tools.wsdlto.core.PluginLoader loadPlugin
ALLVARLIG: Tools plugin jar:file:/C:/Users/Daniel/.m2/repository/org/apache/cxf/cxf-tools-wsdlto-core/3.2.4/cxf-tools-wsdlto-core-3.2.4.jar!/META-INF/tools-plugin.xml load failed

任何可能导致此问题或如何解决问题的想法?

4 个答案:

答案 0 :(得分:2)

遇到同样的问题,我最终改变了插件配置并明确添加了所需的模块:

 <plugin>
     <groupId>org.apache.cxf</groupId>
     <artifactId>cxf-codegen-plugin</artifactId>
     <version>3.2.4</version>
     <configuration>
         <additionalJvmArgs>--add-modules java.xml.bind,java.xml.ws</additionalJvmArgs>
         <fork>once</fork>
     </configuration>
 </plugin>

它似乎适用于Java 9/10,但肯定不适用于Java 11。

答案 1 :(得分:0)

我用Java 10测试过:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.2.4</version>
    <configuration>
        <fork>true</fork>
        <additionalJvmArgs>--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</additionalJvmArgs>
    </configuration>
</plugin>

我的Maven执行文件(Windows):

set PATH=C:\Users\user\Documents\programs\jdk-10\bin;%PATH%
set JAVA_HOME=C:\Users\user\Documents\programs\jdk-10
set MAVEN_OPTS=--add-modules java.xml.bind
mvn clean install

答案 2 :(得分:0)

正如文档所述,您必须从3.2.5 cxf documentation for java 9版开始

<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.5</version>

答案 3 :(得分:0)

在Java 8上运行时,使用--add-modules失败。为了使构建版本与Java 8和Java 9兼容,我添加了javax.xml.bind:jaxb-api作为插件的依赖项 相反,它似乎工作正常。

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <!-- ... -->
    </executions>
    <dependencies>
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
    </dependencies>
</plugin>