英文:
Unable to generate POJO from WSDL using Apache CXF Library Maven
问题
我正在尝试使用Apache CXF库将WSDL文件转换为Java代码,但是我遇到了以下错误:
[ERROR] 执行目标org.apache.cxf:cxf-codegen-plugin:3.2.0:wsdl2java(generate-sources)失败:在执行org.apache.cxf:cxf-codegen-plugin:3.2.0:wsdl2java时缺少所需的类:javax/xml/bind/annotation/adapters/HexBinaryAdapter
以下是POM文件:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>wsdl2javademo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<cxf.version>3.2.0</cxf.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
我尝试过使用不同的逻辑和多个来源,但似乎都没有解决问题。
尝试使用不同的版本、添加依赖等。甚至尝试过参考这个示例项目:https://github.com/dimitrisli/Wsdl2Java
英文:
I am trying to convert WSDL file to Java using the Apache CXF library, however I am getting below error:
[ERROR] Failed to execute goal org.apache.cxf:cxf-codegen-plugin:3.2.0:wsdl2java (generate-sources) on project wsdl2javademo: Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.2.0:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen-plugin:3.2.0:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter
Here is the POM file:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.demo</groupId>
<artifactId>wsdl2javademo</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<cxf.version>3.2.0</cxf.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have tried to use multiple sources with different logics however none of those seems to be solving the purpose.
Trying different version, adding dependencies etc. Even tried going through the sample project: https://github.com/dimitrisli/Wsdl2Java
专注分享java语言的经验与见解,让所有开发者获益!
评论