【问题标题】:jaxws-maven-plugin 1.12 generates methods which are not compatible with jdk1.5jaxws-maven-plugin 1.12 生成与 jdk1.5 不兼容的方法
【发布时间】:2014-06-18 10:52:05
【问题描述】:

我有一个 maven 项目,我使用 jaxws-maven-plugin 如下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>jaxws-maven-plugin</artifactId>
    <version>1.12</version>
    <executions>
        <execution>
            <goals>
                <goal>wsimport</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <wsdlDirectory>src/main/wsdl</wsdlDirectory>
    <wsdlFiles>
            <wsdlFile>MyService.wsdl</wsdlFile>
        </wsdlFiles>
        <sourceDestDir>src/main/java</sourceDestDir>
        <extension>true</extension>
    </configuration>
</plugin>

该项目使用 jdk1.5.0_22 和 jboss 4.2.2.GA 运行。我遇到的问题是 jaxws-maven-plugin 生成的代码不再与 jdk1.5.0_22 兼容。结果,我在编译时收到以下错误:

cannot find symbol : method getPort(javax.xml.namespace.QName,java.lang.Class<com.example.MyService>,javax.xml.ws.WebServiceFeature[]) location: class javax.xml.ws.Service

项目在任何情况下都必须以上述配置(jdk1.5.0_22和jboss 4.2.2.GA)运行,所以我无法升级到jdk1.6。

有什么办法可以解决这个问题吗?

提前感谢您的帮助。

【问题讨论】:

    标签: java maven jboss jboss-4.2.x jdk1.5


    【解决方案1】:

    感谢 win_wave 的评论。事实上,我也已经用这种方式设置了 maven 编译器。

    无论如何,我能够自己解决这个问题。事实上,jaxws-maven-plugin 的 wsimport 目标有一个配置参数,称为 target

    我现在的插件设置如下:

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxws-maven-plugin</artifactId>
        <version>1.12</version>
        <executions>
            <execution>
                <goals>
                    <goal>wsimport</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            ...
            <target>2.0</target>
            ...
        </configuration>
    </plugin>
    

    通过将 target 参数设置为 2.0,插件将生成与 jax-ws 2.0 兼容的代码,因此也与 jdk 1.5 兼容。

    【讨论】:

      【解决方案2】:

      here
      你不见了:

       <!-- Don't forget Java 5!! -->
       <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <configuration>
             <source>1.5</source>
             <target>1.5</target>
          </configuration>
       </plugin>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-04-15
        • 1970-01-01
        • 1970-01-01
        • 2016-01-28
        • 2013-08-30
        • 2022-11-29
        • 1970-01-01
        相关资源
        最近更新 更多