解决错误:Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlType

今天运行项目时出错,原因是原项目在jdk1.8下运行的,升级成jdk11之后缺了一些jar包。

温馨提示:大家在做项目时一定要注意版本问题。

解决方案一:

降低JDK 版本到 JDK 8

解决方案二:

在pom.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-impl</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>javax.activation</groupId>
        <artifactId>activation</artifactId>
        <version>1.1.1</version>
    </dependency>

 至此,问题完美解决,项目成功运行!

打包resource

 <resources>
            <resource>
                <!--需要打包的目录-->
                <directory>src/main/java</directory>
                <!--目录中的文件类型-->
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.xml</include>
                    <include>**/*.properties</include>
                </includes>
            </resource>
        </resources>

  

posted on 2020-03-17 15:25  江上酒,故人倾  阅读(4846)  评论(0编辑  收藏  举报