我正在尝试使用 wsimport 从 WSDL 生成类。
我正在使用由 Netbeans (7.1) 生成的 Maven POP,但是当我尝试构建它时得到以下输出:
[jaxws:wsimport]
Processing: C:\Users\...\src\wsdl\ShipService_v5.wsdl
jaxws:wsimport args: [-s, C:\Users\...\target\generated-sources\jaxws-wsimport, -d, C:\Users\...\target\classes, -verbose, -catalog, C:\Users\...\src\jax-ws-catalog.xml, -wsdllocation, file:/C:/Users/.../Desktop/ShipService_v5.wsdl, -extension, -Xnocompile, C:\Users\...\src\wsdl\ShipService_v5.wsdl]
parsing WSDL...
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 1.361s
Finished at: Mon Apr 09 12:51:52 BST 2012
Final Memory: 4M/120M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:jaxws-maven-plugin:1.10:wsimport (wsimport-generate-ShipService_v5) on project RPDataStreams: Error executing: wsimport [-s, C:\Users\...\target\generated-sources\jaxws-wsimport, -d, C:\Users\...\target\classes, -verbose, -catalog, C:\Users\...\src\jax-ws-catalog.xml, -wsdllocation, file:/C:/Users/.../Desktop/ShipService_v5.wsdl, -extension, -Xnocompile, C:\Users\...\src\wsdl\ShipService_v5.wsdl] -> [Help 1]
我的 POM 中的插件部分是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>ShipService_v5.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>file:/C:/Users/.../Desktop/ShipService_v5.wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/ShipService_v5.stale</staleFile>
</configuration>
<id>wsimport-generate-ShipService_v5</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>
我知道我使用的 WSDL 没有问题,我也用 http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl 的 WSDL 试过了.
我已经尝试从 Netbeans 和从 Ubuntu 服务器的命令行构建这个项目,两次我得到相同的结果。
我现在将其缩小到对 jconfig 的依赖。如果我注释掉下面的 block ,则 Web 服务源已成功构建。
<dependency>
<groupId>org.jconfig</groupId>
<artifactId>jconfig</artifactId>
<version>2.9</version>
<exclusions>
<exclusion>
<artifactId>jmxri</artifactId>
<groupId>com.sun.jmx</groupId>
</exclusion>
</exclusions>
</dependency>
感谢您的帮助。
最佳答案
你应该使用:
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version>
这是最新版本(注意插件已移至 org.jvnet.jax-ws-commons)
编辑:
您可以尝试有选择地排除 jconfig 构建依赖项。完整列表如下所示:
<dependency>
<groupId>org.jconfig</groupId>
<artifactId>jconfig</artifactId>
<version>2.9</version>
<exclusions>
<exclusion>
<groupId>com.sun.jmx</groupId>
<artifactId>jmxri</artifactId>
</exclusion>
<exclusion>
<groupId>javax.xml.parsers</groupId>
<artifactId>jaxp-api</artifactId>
</exclusion>
<exclusion>
<groupId>crimson</groupId>
<artifactId>crimson</artifactId>
</exclusion>
</exclusions>
</dependency>
编辑:你真的需要jconfig吗?如果没有,就摆脱它。
关于java - Wsimport 在 Maven 构建期间失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10073170/