“调用 com.sun.tools.ws.wscompile.WsimportTool 失败”在使用 JDK 1.8 进行编译时出错

问题描述

我正在处理一个项目并尝试从编译器版本迁移。从 JDK 1.7 到 1.8。在构建过程中,我在其中一个模块上收到了以下错误,但我无法解决

REPORT

我正在使用 Failed to execute goal org.codehaus.mojo:jaxws-maven-plugin:2.6:wsimport (default) on project wae-client-jar: Invocation of com.sun.tools.ws.wscompile.WsimportTool Failed - check output 而我的 IntelliJ 版本是 Maven

这是我的 pom.xml 的相关部分:

3.6.3

到目前为止我已经尝试过,

-更新插件配置如下

<plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <wsdlDirectory>src/main/wsdl</wsdlDirectory>
                <packageName>com.company.wae.client.ebif.eps.sopi.wsdl</packageName>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-rt</artifactId>
                    <version>2.2.10</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <version>2.1.6</version>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-xjc</artifactId>
                    <version>2.1.6</version>
                </dependency>
                <dependency>
                    <groupId>com.company.wae.base</groupId>
                    <artifactId>wae-jboss-lib</artifactId>
                    <version>9.8.0</version>
                </dependency>
            </dependencies>
        </plugin>
</plugins>

-将 jaxws-maven-plugin 的版本更改为 2.4.1 并添加以下 dep。到插件

 <configuration>
        <wsdlDirectory>src/main/wsdl</wsdlDirectory>
        <packageName>com.company.wae.client.ebif.eps.sopi.wsdl</packageName>
        <vmArgs>
            <vmArg>-Djavax.xml.accessExternalSchema=all</vmArg>
        </vmArgs>
    </configuration>

-不仅要构建那个模块,还要构建整个项目。

-从本地 repo m2 中删除 jaxws-maven-plugin 和 jaxws-tools 文件夹。

-检查JAVA_HOME路径是否指向JDK1.8。检查项目 SDK (JDK 1.8)

都主要提到了here

这些都没有帮助。

解决方法

通过修复使用 mvn install -e 时的错误,我能够解决此问题。

  • 首先,我将 jaxb-impljaxb-xjc 版本从 2.1.6 升级到 2.2.10

  • 我在下面添加了 jaxb-corejaxws-tools 依赖项。

这是我的 pom.xml 的更新部分:

<plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <wsdlDirectory>src/main/wsdl</wsdlDirectory>
                    <packageName>com.company.wae.client.ebif.eps.sopi.wsdl</packageName>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>com.sun.xml.ws</groupId>
                        <artifactId>jaxws-rt</artifactId>
                        <version>2.2.10</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-impl</artifactId>
                        <version>2.2.10</version>
                    </dependency>
                    <dependency>
                        <groupId>com.sun.xml.bind</groupId>
                        <artifactId>jaxb-xjc</artifactId>
                        <version>2.2.10</version>
                    </dependency>
                    <dependency>
                        <groupId>com.company.wae.base</groupId>
                        <artifactId>wae-jboss-lib</artifactId>
                        <version>9.8.0</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.ws</groupId>
                        <artifactId>jaxws-tools</artifactId>
                        <version>2.2.10</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>