运行springboot项目出现:Type javax.xml.bind.JAXBContext not present

问题:运行springboot项目出现:Type javax.xml.bind.JAXBContext not present

原因

java9+版本以后,JAXB默认没有加载

 

手动添加模块到pom:

    spring boot 2.0.*版本,添加如下代码:

————————————————

<!-- jaxb模块引用 - start -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</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.0</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<!-- jaxb模块引用 - end -->
————————————————

转自:https://blog.csdn.net/alger_magic/article/details/83041811

 

上一篇:解决报错java.lang.TypeNotPresentException: Type javax.xml.bind.JAXBContext not present


下一篇:用Java将XML文档保存在数据库中(Hibernate和JAXB的组合)