用JDK 11替换wsimport

Eti*_*got 9 java spring wsimport

我当前正在开发一个需要wsimport的项目,但是我们使用的是JDK11,我刚刚发现从此版本开始,wsimport已从JDK中删除。

我搜索了答案,并尝试添加此依赖关系,但目前无法正常工作。

     <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.11</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

有什么我不知道的wsimport替代品吗?

谢谢 !

Flo*_*mme 7

今天,你可以使用 fork 来直接替换 org.codehaus.mojo:jaxws-maven-plugin:2.5:

<plugin>
  <groupId>com.helger.maven</groupId>
  <artifactId>jaxws-maven-plugin</artifactId>
  <version>2.6</version>
  <configuration>
    ...
  </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

https://github.com/phax/jaxws-maven-plugin。它适用于 jdk11


Gus*_*ini 6

该插件的最新版本(目前为 2.6)适用于 Java 11。

http://www.mojohaus.org/jaxws-maven-plugin/index.html


Eti*_*got -4

终于有作品了!以防万一有人遇到同样的问题:

我想使用 maven build 来生成源代码,其中 pom.xml :

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.4.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <packageName>my.package</packageName>
                        <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
                        <keep>true</keep>
                        <executable>${java.home}/bin/wsimport</executable>
                        <wsdlDirectory>src/main/resources/schemas</wsdlDirectory>
                        <bindingFiles>
                            <bindingFile>${basedir}/src/bindings/binding.xjb</bindingFile>
                        </bindingFiles>
                        <target>2.1</target>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
Run Code Online (Sandbox Code Playgroud)

但解决方案是直接使用控制台运行 wsimport :

wsimport -d target/generated-sources/jaxws-wsimport/ -s target/generated-sources/jaxws-wsimport/ src/main/resources/schemas/myWSDLFile.wsdl
Run Code Online (Sandbox Code Playgroud)

当然,我使用的是 JDK 11

  • JDK 11 没有 wsimport 工具。所以我不确定你是如何做你所描述的事情的。 (9认同)