我想创建一个用xml响应请求的小REST应用程序。我的应用程序返回普通字符串的基本配置运行良好。
为了增加对pom.xml的支持,我在我的xml中添加了以下内容:
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
但是当eclipse中的tomcat服务器加载应用程序时,我仍然有以下错误:
java.lang.ClassNotFoundException: javax.xml.bind.JAXBContext
我的系统配置:
java --version
openjdk 10.0.1 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10)
OpenJDK 64-Bit Server VM (build 10.0.1+10, mixed mode)
eclipse Version: Photon Release (4.8.0)
tomcat 8.5
发布于 2018-07-28 04:23:01
从Java 9开始,JAXB不再是JDK的一部分。Andy Guibert和this migration guide编写的This explanation应该会帮助您理解这种情况。
因此,“一个又快又脏的解决方案”是将--add-modules java.xml.bind
添加到您的编译过程中。
https://stackoverflow.com/questions/51564844
复制相似问题