首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >用JDK 11替换wsimport

用JDK 11替换wsimport
EN

Stack Overflow用户
提问于 2018-11-13 01:02:00
回答 5查看 30.1K关注 0票数 19

我目前正在做一个需要wsimport的项目,但是我们使用的是JDK11,我刚刚发现wsimport从JDK中删除了。

我寻找答案,并尝试添加此依赖项,但目前不起作用。

代码语言:javascript
运行
复制
     <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.11</version>
    </dependency>

有没有我不知道的wsimport的替代品?

谢谢!

EN

Stack Overflow用户

发布于 2019-01-16 19:43:58

jaxws-maven-plugin还没有更新到JDK11。项目上有一个pull request,但它还没有合并。

这里提出了wsimport的一个临时解决方案:https://github.com/javaee/metro-jax-ws/issues/1251#issuecomment-441424365,它可能在Linux上工作得很好。

在我们的项目中,我们使用Windows环境,并根据以下示例修复了wsimport:

代码语言:javascript
运行
复制
<plugins>
    <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>1.8</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <configuration>
                    <target>
                        <mkdir dir="target/generated-sources/wsimport"/>

                        <property name="plugin_classpath" refid="maven.plugin.classpath" />

                        <exec executable="java">
                            <arg value="-classpath"/>
                            <arg value="${plugin_classpath}"/>
                            <arg value="com.sun.tools.ws.WsImport"/>
                            <arg value="-extension"/>
                            <arg value="-Xnocompile"/>
                            <arg value="-wsdllocation"/>
                            <arg value="/MyWSDL.wsdl"/>
                            <arg value="-s"/>
                            <arg value="target/generated-sources/wsimport"/>
                            <arg value="-p"/>
                            <arg value="com.company.client.generated"/>
                            <arg value="src/main/resources/MyWSDL.wsdl"/>
                        </exec>
                    </target>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>ant-contrib</groupId>
                <artifactId>ant-contrib</artifactId>
                <version>1.0b2</version>
            </dependency>
            <dependency>
                <groupId>javax.jws</groupId>
                <artifactId>javax.jws-api</artifactId>
                <version>1.1</version>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-core</artifactId>
                <version>2.3.0.1</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.bind</groupId>
                <artifactId>jaxb-impl</artifactId>
                <version>2.3.2</version>
            </dependency>

            <!-- xml.ws module -->
            <dependency>
                <groupId>javax.xml.ws</groupId>
                <artifactId>jaxws-api</artifactId>
                <version>2.3.1</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.ws</groupId>
                <artifactId>jaxws-rt</artifactId>
                <version>2.3.1</version>
                <exclusions>
                    <exclusion>
                        <!-- declare the exclusion here -->
                        <groupId>org.glassfish.jaxb</groupId>
                        <artifactId>txw2</artifactId>
                    </exclusion>
                </exclusions> 
            </dependency>

            <!-- javax.activation -->
            <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1.1</version>
            </dependency>

            <!-- wsimport -->
            <dependency>
                <groupId>com.sun.xml.ws</groupId>
                <artifactId>jaxws-tools</artifactId>
                <version>2.3.1</version>
                <scope>compile</scope>
            </dependency>
        </dependencies>
    </plugin>
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
            <execution>
                <id>add-source</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>add-source</goal>
                </goals>
                <configuration>
                    <sources>
                        <source>target/generated-sources/wsimport</source>
                    </sources>
                </configuration>
            </execution>
        </executions>
    </plugin>
</plugins>
票数 1
EN
查看全部 5 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53266846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档