0

我想在我的骆驼 maven 项目中使用 cxf-codegen-plugin 生成带有 wsdl2java 的源。

我将插件如下添加到我的 pom.xml 中。

<plugin>
   <groupId>org.apache.cxf</groupId>
   <artifactId>cxf-codegen-plugin</artifactId>
   <version>3.2.4</version>
   <executions>
     <execution>
       <id>generate-sources</id>
       <phase>generate-sources</phase>
       <configuration>
         <wsdlOptions>
           <wsdlOption>
             <wsdl>src/main/resources/wsdl/BookService.wsdl</wsdl>
           </wsdlOption>
         </wsdlOptions>
       </configuration>
       <goals>
         <goal>wsdl2java</goal>
       </goals>
     </execution>
   </executions>
 </plugin>

这会在 pom 中引发错误...

Execution generate-sources of goal org.apache.cxf:cxf-codegen-plugin:3.2.4:wsdl2java failed: A required class was missing while executing org.apache.cxf:cxf-codegen-
 plugin:3.2.4:wsdl2java: javax/xml/bind/annotation/adapters/HexBinaryAdapter ----------------------------------------------------- realm = plugin>org.apache.cxf:cxf-codegen-
 plugin:3.2.4 strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy urls[0] = file:/C:/esb/.m2/repository/org/apache/cxf/cxf-codegen-plugin/3.2.4/cxf-codegen-
 plugin-3.2.4.jar urls[1] = file:/C:/esb/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.5/plexus-utils-2.0.5.jar urls[2] = file:/C:/esb/.m2/repository/org/codehaus/plexus/plexus-
 archiver/1.2/plexus-archiver-1.2.jar ...

我尝试了其他示例项目,例如https://github.com/sigreen/camel-cxf-soap-client并在 pom 中遇到了类似的错误因为我确信它在 2015 年提交该项目时可以恢复,我认为它是今天版本不匹配。

如果有人最近有一个带有 cxf-codegen-plugin 的项目,那会有所帮助。

4

1 回答 1

0

我不断根据错误堆栈中的细节进行更改,这些细节随着每次更改而不断变化。这是 pom 中最后一个干净的插件条目...

<plugin>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-codegen-plugin</artifactId>
                <version>3.2.4</version>
                <dependencies>
                    <!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
                    <dependency>
                        <groupId>javax.xml.bind</groupId>
                        <artifactId>jaxb-api</artifactId>
                        <version>2.3.1</version>
                    </dependency>
                    <!-- https://mvnrepository.com/artifact/javax.xml.ws/jaxws-api -->
                    <dependency>
                        <groupId>javax.xml.ws</groupId>
                        <artifactId>jaxws-api</artifactId>
                        <version>2.1</version>
                    </dependency>
                    <!-- https://mvnrepository.com/artifact/javax.jws/javax.jws-api -->
                    <dependency>
                        <groupId>javax.jws</groupId>
                        <artifactId>javax.jws-api</artifactId>
                        <version>1.1</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdlOptions>
                                <wsdlOption>
                                    <wsdl>src/main/resources/wsdl/BookService.wsdl</wsdl>
                                </wsdlOption>
                            </wsdlOptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
于 2021-06-01T03:48:07.637 回答