jaxws-api 2.2 not loaded in maven build

巧了我就是萌 提交于 2020-01-13 10:53:09

问题


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>

On build, I get these errors in Maven:

cannot find symbol symbol : constructor Service(java.net.URL,javax.xml.namespace.QName,javax.xml.ws.WebServiceFeature[])

I have checked JAX-WS API 2.2 and it actually has this constructor...what should I do?


回答1:


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.

This page has the gory details.

The critical snippet is:

   <!-- 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>


来源:https://stackoverflow.com/questions/15722399/jaxws-api-2-2-not-loaded-in-maven-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!