无法使用Apache CXF库的Maven从WSDL生成POJO。

huangapple 未分类评论52阅读模式
英文:

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:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;com.demo&lt;/groupId&gt;
    &lt;artifactId&gt;wsdl2javademo&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;

    &lt;properties&gt;
        &lt;cxf.version&gt;3.2.0&lt;/cxf.version&gt;
    &lt;/properties&gt;


    &lt;build&gt;
        &lt;plugins&gt;
            &lt;plugin&gt;
                &lt;groupId&gt;org.apache.cxf&lt;/groupId&gt;
                &lt;artifactId&gt;cxf-codegen-plugin&lt;/artifactId&gt;
                &lt;version&gt;${cxf.version}&lt;/version&gt;
                &lt;executions&gt;
                    &lt;execution&gt;
                        &lt;id&gt;generate-sources&lt;/id&gt;
                        &lt;phase&gt;generate-sources&lt;/phase&gt;
                        &lt;configuration&gt;
                            &lt;sourceRoot&gt;${project.build.directory}/generated-sources/cxf&lt;/sourceRoot&gt;
                            &lt;wsdlOptions&gt;
                                &lt;wsdlOption&gt;
                                    &lt;wsdl&gt;${basedir}/src/main/resources/myService.wsdl&lt;/wsdl&gt;
                                &lt;/wsdlOption&gt;
                            &lt;/wsdlOptions&gt;
                        &lt;/configuration&gt;
                        &lt;goals&gt;
                            &lt;goal&gt;wsdl2java&lt;/goal&gt;
                        &lt;/goals&gt;
                    &lt;/execution&gt;
                &lt;/executions&gt;
            &lt;/plugin&gt;
        &lt;/plugins&gt;
    &lt;/build&gt;
&lt;/project&gt;

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

huangapple
  • 本文由 发表于 2020年5月2日 18:19:05
  • 转载请务必保留本文链接:https://java.coder-hub.com/61557727.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定