异常:Type javax.xml.bind.JAXBContext not present

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

原因是:java9模块化的概念使得JAXB默认没有加载;

jaxb-api是存在jdk中的,只是默认没有加载而已,手动引入即可。

<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-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>

java9模块命令方式:

--add-modles java.xml.bind

java9默认未加载模块:

javax.activation
javax.corba
javax.transaction
javax.xml.bind
javax.xml.ws
javax.xml.ws.annotation

    原文作者:龙神之飞绝
    原文地址: https://zhuanlan.zhihu.com/p/53241366
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞