Spring Boot启动异常:java.lang.TypeNotPresentException

最近使用Spring Cloud和Spring Boot做项目时,出现了这个异常:

java.lang.TypeNotPresentException: Type javax.xml.bind.JAXBContext not prese

 解决方案:

先将Spring Boot的内置服务器替换掉,在pom.xml中做出如下修改:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    <exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<dependency>
    <groupId>org.apache.tomcat.embed</groupId>
    <artifactId>tomcat-embed-jasper</artifactId>
    <scope>provided</scope>
</dependency>

然后,在pom.xml中添加如下依赖:

以下内容来自博客:https://blog.csdn.net/qq_15807167/article/details/79346607

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

猜你喜欢

转载自blog.csdn.net/wzy18210825916/article/details/83790469
今日推荐