将java版本从java 8更改为java 17后,无法执行目标org.jvnet.jaxb2.maven2

问题描述 投票:0回答:1

这些是我将 java 版本从 java 8 更改为 java 17 后遇到的与 jaxb 相关的错误。

BUILD FAILURE
[INFO] Finished at: 2024-02-22T18:46:54+05:30
[INFO]

[ERROR] Failed to execute goal org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.0: generate (WSDL2JAVA) on project ENService: Execution WSDL2JAVA of goal org.jvnet.jaxb2.maven2:maven-jaxh2 plugin:0.13.0:generate failed: A required class was missing while executing org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.0:generate: com/sun/xml/bind/api/ErrorListener

ERROR

ERROR] realm plugin>org.jvnet.jaxb2.maven2:maven-jaxb2-plugin:0.13.0 ERROR] strategy org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy

ERROR

] urls[0] = file:/C:/Users/PJ78398/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin/0.13.0/maven-jaxb2-plugin-0.13.0.jar

ERROR] urls[1] = file:/C:/Users/P378398/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb2-plugin-core/0.13.0/maven-jaxb2-plugin-core-0.13.0.jar

ERROR] urls[2] file:/C:/Users/P378398/.m2/repository/org/apache/commons/commons-lang3/3.2.1/commons-lang3-3.2.1.jar ERROR] urls[3]file:/C:/Users/P378398/.m2/repository/com/sun/org/apache/xml/internal/resolver/20050927/resolver-20050927.jar

ERROR] urls[4] file:/C:/Users/P378398/.m2/repository/org/sonatype/plexus/plexus-build-api/e.e.7/plexus-build-api-0.0.7.jar ERROR] urls[5] file:/C:/Users/PJ78398/.m2/repository/junit/junit/4.8.1/junit-4.8.1.jar

ERROR] urls[6] = file:/C:/Users/P378398/.m2/repository/org/codehaus/plexus/plexus-utils/1.5.15/plexus-utils-1.5.15. jar

ERROR] urls[7] file:/C:/Users/P378398/.m2/repository/org/jvnet/jaxb2/maven2/maven-jaxb22-plugin/0.13.0/maven-jaxb22-plugin-0.13.0.jar file:/C:/Users/P378398/.m2/repository/org/glassfish/jaxb/jaxb-runtime/2.2.11/jaxb-runtime-2.2.11.jar

ERROR] urls[8] =

ERROR] urls[9] file:/C:/Users/P378398/.m2/repository/org/glassfish/jaxb/jaxb-xjc/2.2.11/jaxb-xjc-2.2.11.jar ERROR] urls[10] file:/C:/Users/P378398/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.4/maven-plugin-annotations-3.4.jar

ERROR] Number of foreign imports: 1

ERROR

] import: Entry[import from realm ClassRealm[maven.api, parent: null]]

这是我正在使用的插件

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <version>0.13.0</version>
    <executions>
        <execution>
            <id>WSDL2JAVA</id>
            <goals>
                <goal>generate</goal>
            </goals>
            <configuration>
                <schemaDirectory>config</schemaDirectory>
                <schemaLanguage>WSDL</schemaLanguage>
                <schemaIncludes>
                    <include>*.wsdl</include>
                </schemaIncludes>
            </configuration>
        </execution>
    </executions>
</plugin>

我已经尝试过了,但构建仍然失败。

当然!以下是根据博客文章更新 ENservice 模块中的

pom.xml
文件的方法:

<project>
    ...
    <properties>
        <!-- Set the JDK version to 17 -->
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>

    <build>
        <plugins>
            <!-- Update the maven-compiler-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>17</source>
                    <target>17</target>
                </configuration>
            </plugin>

            <!-- Update the maven-jaxb2-plugin -->
            <plugin>
                <groupId>org.jvnet.jaxb2.maven2</groupId>
                <artifactId>maven-jaxb2-plugin</artifactId>
                <version>0.14.0</version>
                <executions>
                    <execution>
                        <id>WSDL2JAVA</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <schemaDirectory>config</schemaDirectory>
                            <schemaLanguage>WSDL</schemaLanguage>
                            <schemaIncludes>
                                <includes>
                                 <include>*..wsdl</include>
                           </schemaIncludes>

还有这些依赖项

<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>

在此之后建筑仍然失败。有什么建议吗?
提前谢谢你:)

java spring jaxb maven-jaxb2-plugin
1个回答
0
投票

由于您似乎以 JAXB 2.3 为目标,因此您应该检查 迁移指南 以获取最新版本的插件(选择 2.0.9 版本,这是支持 JAXB 2.3 的当前最新版本)

从以下位置移动:

<!-- Update the maven-jaxb2-plugin -->
<plugin>
  <groupId>org.jvnet.jaxb2.maven2</groupId>
  <artifactId>maven-jaxb2-plugin</artifactId>
  <version>0.14.0</version>
...
</plugin>

致以下人士:

<plugin>
  <groupId>org.jvnet.jaxb</groupId>
  <artifactId>jaxb-maven-plugin</artifactId>
  <version>2.0.9</version>
...
</plugin>
© www.soinside.com 2019 - 2024. All rights reserved.