java xml soap,Java 11软件包javax.xml.soap不存在
I'm trying to create a simple message using SOAP:
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
When I build the project with Java 8 it's fine, but building it with Java 11 fails with a compilation error:
package javax.xml.soap does not exist
How do I fix the issue?
解决方案
JAX-WS removed from Java 11
JAX-WS is no longer bundled with Java 11.
According to the release notes, Java 11 removed the Java EE modules:
java.xml.ws (JAX-WS, plus the related technologies SAAJ and Web Services Metadata) - REMOVED
Java 8 - OK
Java 9 - DEPRECATED
Java 10 - DEPRECATED
Java 11 - REMOVED
See JEP 320 for more info.
You can fix the issue by using alternate versions of the Java EE technologies. Simply add a com.sun.xml.ws : jaxws-ri Maven artifact that contains the technologies you need:
com.sun.xml.ws
jaxws-ri
2.3.2
pom
Jakarta EE 8 update (Mar 2020)
Instead of using old JAX-WS module you can fix the issue by using Jakarta XML Web Services from Jakarta EE 8:
jakarta.xml.ws
jakarta.xml.ws-api
2.3.3
com.sun.xml.ws
jaxws-rt
2.3.3
runtime
Jakarta EE 9 update (Nov 2020)
Use latest release of Jakarta XML Web Services 3.0:
compatible implementation jaxws-rt
jakarta.xml.ws
jakarta.xml.ws-api
3.0.0
com.sun.xml.ws
jaxws-rt
3.0.0
runtime
Note: change javax.* imports to jakarta.*
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)