XJC Maven 插件(jaxb2-maven-plugin) Java 11 迁移问题
XJC Maven Plugin(jaxb2-maven-plugin) Java 11 Migration Issues
我目前正在处理 java 11 迁移项目,其中 jaxb2-maven-plugin 已用于 XJC 任务。由于 XJC 可执行文件不存在于 JDK 11 版本中,我收到以下提到的错误。
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc (xjc-schema1) on project paymaster-service: Execution xjc-schema1 of goal org.codehaus.mojo:jaxb2-maven-plugin:2.2
:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc: com/sun/codemodel/CodeWriter
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:jaxb2-maven-plugin:2.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/voletis/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/2.2/jaxb2-maven-plugin-2.2.jar
[ERROR] urls[1] = file:/C:/Users/voletis/.m2/repository/javax/xml/bind/jaxb-api/2.2.11/jaxb-api-2.2.11.jar
[ERROR] urls[2] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-core/2.2.11/jaxb-core-2.2.11.jar
[ERROR] urls[3] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
[ERROR] urls[4] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
[ERROR] urls[5] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-jxc/2.2.11/jaxb-jxc-2.2.11.jar
[ERROR] urls[6] = file:/C:/Users/voletis/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M3/qdox-2.0-M3.jar
[ERROR] urls[7] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[8] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[9] = file:/C:/Users/voletis/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] urls[10] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[11] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[12] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[13] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[14] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.5/plexus-compiler-api-2.5.jar
[ERROR] urls[15] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[16] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : com.sun.codemodel.CodeWriter
[ERROR] -> [Help 1]
[ERROR]
下面是我的pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.2</target>
<schemaFiles>SubmitPaymentBatch/SubmitPaymentRequest.xsd</schemaFiles>
<packageName>app.test.services.submitpayment.request</packageName>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</plugin>
我已根据 java 11 项要求添加了必要的依赖项,如 JAXB、JAXB-IMPL 等。但仍然无法解决问题。您对此有任何建议的修复方法吗?提前致谢。
我刚刚找到了将 jaxb2-maven-plugin 与 Java 11 一起使用时出现问题的解决方法。它包括在 pom.xml 中添加额外的依赖项并添加额外的虚拟 [=16] =] 文件添加到项目中,在适当的 XSD 文件旁边。我已经把它完全放在我的博客-post 在这里:
https://artofcode.wordpress.com/2019/02/26/jaxb2-maven-plugin-2-4-and-java-11/
我已经按照以下参考 link 解决了这个问题。
https://github.com/davidmoten/jax-maven-plugin
根据上面的教程参考,我修改了我的插件如下,我可以解决这个问题。
<plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>VERSION_HERE</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.2</target>
<schemaFiles>SubmitPaymentBatch/SubmitPaymentRequest.xsd</schemaFiles>
<packageName>app.test.services.submitpayment.request</packageName>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
</plugin>
jaxb2-maven-plugin 2.5.0 现在兼容 Java 11:
我能够通过添加此处列出的所有依赖项来解决 JDK11 的问题:https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/pom.xml#L251-L290 apache.cxf 项目在其示例项目中使用的 JDK9
我在让 jaxb 与 maven 和 Java 11 一起工作时遇到了问题。我的解决方案如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>de.powerstat.my.generated</packageName>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</plugin>
希望这对其他人有帮助。
我目前正在处理 java 11 迁移项目,其中 jaxb2-maven-plugin 已用于 XJC 任务。由于 XJC 可执行文件不存在于 JDK 11 版本中,我收到以下提到的错误。
[ERROR] Failed to execute goal org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc (xjc-schema1) on project paymaster-service: Execution xjc-schema1 of goal org.codehaus.mojo:jaxb2-maven-plugin:2.2
:xjc failed: A required class was missing while executing org.codehaus.mojo:jaxb2-maven-plugin:2.2:xjc: com/sun/codemodel/CodeWriter
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:jaxb2-maven-plugin:2.2
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/voletis/.m2/repository/org/codehaus/mojo/jaxb2-maven-plugin/2.2/jaxb2-maven-plugin-2.2.jar
[ERROR] urls[1] = file:/C:/Users/voletis/.m2/repository/javax/xml/bind/jaxb-api/2.2.11/jaxb-api-2.2.11.jar
[ERROR] urls[2] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-core/2.2.11/jaxb-core-2.2.11.jar
[ERROR] urls[3] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar
[ERROR] urls[4] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar
[ERROR] urls[5] = file:/C:/Users/voletis/.m2/repository/org/glassfish/jaxb/jaxb-jxc/2.2.11/jaxb-jxc-2.2.11.jar
[ERROR] urls[6] = file:/C:/Users/voletis/.m2/repository/com/thoughtworks/qdox/qdox/2.0-M3/qdox-2.0-M3.jar
[ERROR] urls[7] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-inject-bean/1.4.2/sisu-inject-bean-1.4.2.jar
[ERROR] urls[8] = file:/C:/Users/voletis/.m2/repository/org/sonatype/sisu/sisu-guice/2.1.7/sisu-guice-2.1.7-noaop.jar
[ERROR] urls[9] = file:/C:/Users/voletis/.m2/repository/org/sonatype/aether/aether-util/1.7/aether-util-1.7.jar
[ERROR] urls[10] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[11] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[12] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[13] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[14] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.5/plexus-compiler-api-2.5.jar
[ERROR] urls[15] = file:/C:/Users/voletis/.m2/repository/org/codehaus/plexus/plexus-utils/3.0.22/plexus-utils-3.0.22.jar
[ERROR] urls[16] = file:/C:/Users/voletis/.m2/repository/org/sonatype/plexus/plexus-build-api/0.0.7/plexus-build-api-0.0.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : com.sun.codemodel.CodeWriter
[ERROR] -> [Help 1]
[ERROR]
下面是我的pom.xml
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.2</target>
<schemaFiles>SubmitPaymentBatch/SubmitPaymentRequest.xsd</schemaFiles>
<packageName>app.test.services.submitpayment.request</packageName>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</plugin>
我已根据 java 11 项要求添加了必要的依赖项,如 JAXB、JAXB-IMPL 等。但仍然无法解决问题。您对此有任何建议的修复方法吗?提前致谢。
我刚刚找到了将 jaxb2-maven-plugin 与 Java 11 一起使用时出现问题的解决方法。它包括在 pom.xml 中添加额外的依赖项并添加额外的虚拟 [=16] =] 文件添加到项目中,在适当的 XSD 文件旁边。我已经把它完全放在我的博客-post 在这里: https://artofcode.wordpress.com/2019/02/26/jaxb2-maven-plugin-2-4-and-java-11/
我已经按照以下参考 link 解决了这个问题。
https://github.com/davidmoten/jax-maven-plugin
根据上面的教程参考,我修改了我的插件如下,我可以解决这个问题。
<plugin>
<groupId>com.github.davidmoten</groupId>
<artifactId>jax-maven-plugin</artifactId>
<version>VERSION_HERE</version>
<executions>
<execution>
<id>xjc-schema1</id>
<goals>
<goal>xjc</goal>
</goals>
<configuration>
<target>2.2</target>
<schemaFiles>SubmitPaymentBatch/SubmitPaymentRequest.xsd</schemaFiles>
<packageName>app.test.services.submitpayment.request</packageName>
<clearOutputDir>false</clearOutputDir>
</configuration>
</execution>
</executions>
</plugin>
jaxb2-maven-plugin 2.5.0 现在兼容 Java 11:
我能够通过添加此处列出的所有依赖项来解决 JDK11 的问题:https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/pom.xml#L251-L290 apache.cxf 项目在其示例项目中使用的 JDK9
我在让 jaxb 与 maven 和 Java 11 一起工作时遇到了问题。我的解决方案如下所示:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>2.5.0</version>
<executions>
<execution>
<id>xjc</id>
<phase>generate-sources</phase>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<packageName>de.powerstat.my.generated</packageName>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>2.3.3</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0.1</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>2.3.3</version>
</dependency>
</dependencies>
</plugin>
希望这对其他人有帮助。