提问人:user22240775 提问时间:7/17/2023 最后编辑:user22240775 更新时间:11/11/2023 访问量:227
无法使用 jaxb-runtime 4.0.3 和 maven-jaxb2-plugin 0.15.3 从 .wsdl 文件生成 java 存根
Not able to generate java stubs from .wsdl files using jaxb-runtime 4.0.3 and maven-jaxb2-plugin 0.15.3
问:
我正在使用 Java 17。如果我使用 jaxb-runtime 2.3.3 和 maven-jaxb2-plugin 0.14.0,它可以正常工作。我需要升级到 jaxb-runtime 4.0.3。在.xjb中,我用jakarta.xml.bind.annotation.XmlRootElement替换了所有javax.xml.bind.annotation.XmlRootElement,用 http://jakarta.ee/xml/ns/jaxb 替换了所有 http://java.sun.com/xml/ns/jaxb。但是出现以下错误:
Error injecting: org.jvnet.mjiip.v_2.XJC2Mojo java.lang.NoClassDefFoundError: com/sun/xml/bind/api/ErrorListener.
我的pom.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.skf.messaging</groupId>
<artifactId>common-messaging-ws-objects</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>common-messaging-ws-objects</name>
<description>common-messaging-ws-objects</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.release>17</maven.compiler.release>
<log4j2.version>2.17.0</log4j2.version>
<sonar.dependencyCheck.htmlReportPath>./target/dependency-check-report.html</sonar.dependencyCheck.htmlReportPath>
<sonar.dependencyCheck.jsonReportPath>./target/dependency-check-report.json</sonar.dependencyCheck.jsonReportPath>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.3</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>wcl</id>
<url>https://pkgs.dev.azure.com/skforg/WCL-2020/_packaging/wcl/maven/v1</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</distributionManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.owasp</groupId>
<artifactId>dependency-check-maven</artifactId>
<version>7.4.4</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
<format>json</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>${maven.compiler.release}</release>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.15.3</version>
<dependencies>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
<version>4.0.3</version>
</dependency>
</dependencies>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
<extension>true</extension>
<args>
<arg>-Xannotate</arg>
</args>
<plugins>
<plugin>
<groupId>org.jvnet.jaxb2_commons</groupId>
<artifactId>jaxb2-basics-annotate</artifactId>
<version>1.1.0</version>
</plugin>
</plugins>
<schemaDirectory>${project.basedir}/src/main/resources/wsdl</schemaDirectory>
<schemaIncludes>
<include>*.wsdl</include>
</schemaIncludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
答:
0赞
Laurent Schoelens
11/11/2023
#1
maven 插件已更新为支持 jakarta 命名空间(jaxb api 3 和 4)。
您可以按照迁移指南进行操作,以帮助您更新项目配置以使用 jaxb-tools 的 v4 版本。
如果需要,请随时创建 github 问题,我们很乐意为您提供更多帮助以使其正常工作(或者如果迁移指南不完整/不明显,请提供反馈,以便我们可以更新它以帮助其他用户)。
问候
评论