问题描述
我已经使用Apache CXF工具wsdl2java生成了Java代码.在我对服务的评论中,它说我应该认可Jaxws API 2.2,但不知道这意味着什么.在我的Maven POM中,我有这个:
I have generated Java code with Apache CXF tool wsdl2java. In the comments of my service it says that I should endorse Jaxws API 2.2 but don't know what it means. In my Maven POM I have this:
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2</version>
</dependency>
在构建时,我在Maven中遇到以下错误:
On build, I get these errors in Maven:
我已经检查了JAX-WS API 2.2,它实际上具有此构造函数...我该怎么办?
I have checked JAX-WS API 2.2 and it actually has this constructor...what should I do?
推荐答案
JAX-WS是JDK的一部分.要使用较新的版本,必须将其放在认可的目录中.要使用Maven做到这一点,您必须使用maven-compiler-plugin对其进行配置.
JAX-WS is part of the JDK. To use a newer version, you have to put it in the endorsed directory. To do that with Maven, you have to configure it with the maven-compiler-plugin.
此页面包含了详细信息.
关键片段是:
<!-- Don't forget to use endorsed with JAX-WS 2.2 on Java 6 !! -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArguments>
<endorseddirs>${project.build.directory}/endorsed</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/endorsed</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.4</version>
<type>jar</type>
</artifactItem>
<artifactItem>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2.8</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
这篇关于jaxws-api 2.2未在Maven构建中加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!