【问题标题】:jaxws-api 2.2 not loaded in maven buildjaxws-api 2.2 未在 Maven 构建中加载
【发布时间】:2013-03-30 19:12:41
【问题描述】:
我已经使用 Apache CXF 工具 wsdl2java 生成了 Java 代码。在我的服务的 cmets 中,它说我应该支持 Jaxws API 2.2,但不知道这意味着什么。在我的 Maven POM 中,我有这个:
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.2</version>
</dependency>
在构建时,我在 Maven 中收到以下错误:
找不到符号
符号:构造函数
服务(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])
我检查了 JAX-WS API 2.2,它实际上有这个构造函数……我该怎么办?
【问题讨论】:
标签:
jax-ws
cxf
maven-3
endorsed
【解决方案1】:
JAX-WS 是 JDK 的一部分。要使用较新的版本,您必须将其放在 endorsed 目录中。要使用 Maven 执行此操作,您必须使用 maven-compiler-plugin 对其进行配置。
This page 有血淋淋的细节。
关键的sn-p是:
<!-- 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>