Java 11:导入javax.xml.ws.WebFault:“无法解析符号ws"; [英] Java 11: import javax.xml.ws.WebFault: "Cannot resolve symbol ws"

查看:1202
本文介绍了Java 11:导入javax.xml.ws.WebFault:“无法解析符号ws";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将服务升级到Java11.

I'm attempting to upgrade a service to Java 11.

我们当前使用wsdl2java(Apache CXF)生成基于WSDL的源代码.我正在通过Maven进行所有操作.源文件会根据wsdl正确生成.

We currently use wsdl2java (Apache CXF) to generate source code based on WSDLs. I'm doing this all via Maven. The source files generate properly based on the wsdl.

不幸的是,生成的某些源文件包括以下导入:

Unfortunately, some of the source files generated include the following imports:

import javax.xml.ws.WebFault; 
import javax.jws.WebService;

我缺少javax.xml.ws和javax.jws软件包.

I'm missing the packages javax.xml.ws and javax.jws.

在我的研究中,我发现Jaxb在主要JDK中已弃用,因此我需要在pom中添加新的依赖项.我尝试了各种组合,但它们都可以归结为:

In my research, I have discovered that Jaxb was deprecated out of the main JDK, thus I need to add new dependencies into my pom. I've tried various combinations, but they all come down to something like:

    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</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.0</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish.jaxb</groupId>
        <artifactId>jaxb-runtime</artifactId>
        <version>2.3.2</version>
    </dependency>

不幸的是,无论我做什么,我的IDE似乎都找不到javax.xml.ws和javax.jws.

Unfortunately, no matter what I do, my IDE just can't seem to find javax.xml.ws and javax.jws.

有人知道我可能需要包括哪些依赖关系才能获得这些软件包吗?

Does anyone know what dependency I may need to include so that I get these packages?

尽管这不是问题的核心,但这是我的wsdl2java内容:

And though it's not specifically at the core of the problem, here's my wsdl2java stuff:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.3.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated-sources/cxf/</sourceRoot>

                <wsdlRoot>src/main/webapp/resources/wsdl/fedex</wsdlRoot>
                <includes>
                    <include>**/*.wsdl</include>
                </includes>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

(是的,我正在生成联邦快递客户端).

(Yes, I'm generating a fedex client).

推荐答案

由于经常发生,我在发布此问题后立即找到了答案.我添加了一个额外的依赖项,并且似乎已经解决了它.添加的依赖项是:

As so often happens, I found the answer to this right after posting this question. I added an additional dependency, and that seems to have fixed it. Added dependency was:

    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-ri</artifactId>
        <version>2.3.0</version>
        <type>pom</type>
    </dependency>

我所有的Jaxb依赖项都看起来像...

All my Jaxb dependencies together look like...

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</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.0</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.ws</groupId>
    <artifactId>jaxws-ri</artifactId>
    <version>2.3.0</version>
    <type>pom</type>
</dependency>

这篇关于Java 11:导入javax.xml.ws.WebFault:“无法解析符号ws";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆