我正在使用jaxws-maven-plugin
根据WSDL文件生成一些JAX-WS客户端。
我需要使用JDK 1.6,因此我正在使用JAX-WS Tools 2.1.7执行
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.7</version>
</dependency>
如果我在2.1.7 jaxws-tools上使用
jaxws-maven-plugin
2.2.1
或2.3
的最新版本,则我的构建将无法正常工作,因为在命令行中添加了无效的-encoding参数。unrecognized parameter -encoding
完整命令是
[DEBUG] cmd.exe /X /C ""C:\Program Files\Java\jdk1.6.0_45\jre\bin\java.exe" -Xbootclasspath/p:.m2\repository\javax\xml\bind\jaxb-api\2.1\jaxb-api-2.1.jar;.m2\repository\javax\xml\soap\saaj-api\1.3\saaj-api-1.3.jar;.m2\repository\javax\xml\ws\jaxws-api\2.1\jaxws-api-2.1.jar org.jvnet.jax_ws_commons.jaxws.Invoker com.sun.tools.ws.wscompile.WsimportTool -keep -s <some dir> -d <some dir> -encoding UTF-8 -p <some package> file:<some wsdl file>"
以下pom.xml正常运行,我使用2.2,它不发送编码参数。
<build>
<plugins>
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.2</version> <!-- This version works fine -->
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlDirectory>src/wsdl</wsdlDirectory>
<sourceDestDir>src/main/java</sourceDestDir>
<wsdlFiles>
<wsdlFile>ConsultarStatusNfe.wsdl</wsdlFile>
</wsdlFiles>
<!-- for JDK 6 compilation compatibility -->
<xnocompile>false</xnocompile>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.1.7</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
最佳答案
通过设置<target>2.1</target>
配置,我可以使用最新版本。
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase/>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlDirectory>src/wsdl</wsdlDirectory>
<sourceDestDir>src/main/generated</sourceDestDir>
<wsdlFiles>
<wsdlFile>myfile.wsdl</wsdlFile>
</wsdlFiles>
<packageName>com.souzacruz.pwnfeintegrator</packageName>
<!-- for JDK 6 compilation compatibility -->
<xnocompile>false</xnocompile>
<target>2.1</target>
</configuration>
<dependencies>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-tools</artifactId>
<version>2.2.10</version>
</dependency>
</dependencies>
</plugin>