JAVA - 找不到 com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl

gui*_*dev 6 java soap soap-client

我正在开发一个使用 SOAP 请求使用 Web 服务的应用程序。

有时我会收到此错误:

filters.LoggerFilter:92 - org.springframework.web.util.NestedServletException: Handler processing failed; nested exception is java.lang.Error: javax.xml.soap.SOAPException: Unable to create SAAJ meta-factoryProvider com.sun.xml.internal.messaging.saaj.soap.SAAJMetaFactoryImpl not found
Run Code Online (Sandbox Code Playgroud)

奇怪的是我随机得到这个错误,但我似乎无法找出原因。

我什至添加了一个新的依赖项,但它似乎并没有解决这个问题:

    <dependency>
        <groupId>com.sun.xml.messaging.saaj</groupId>
        <artifactId>saaj-impl</artifactId>
        <version>1.3</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

小智 8

我在使用 Java 11 创建使用 SOAP 请求的应用程序时遇到了同样的问题。

我添加了新的依赖项,对我来说效果很好。

<dependency>
    <groupId>com.sun.xml.messaging.saaj</groupId>
    <artifactId>saaj-impl</artifactId>
    <version>1.5.1</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)


rah*_*mli 2

对于那些在 Java SDK 9+ 下使用 Spring Boot 在 intellij IDEA 中遇到此问题的人,您必须--add-modules java.se.ee在 VM 参数中显式包含(编辑配置 -> VM 选项)。这个答案可能有助于解决与新 Java 模块相关的其他导入问题