为了账号安全,请及时绑定邮箱和手机立即绑定

Spring Boot 应用程序在 IntelliJ 中启动失败

Spring Boot 应用程序在 IntelliJ 中启动失败

qq_笑_17 2023-08-16 10:10:02
我以前有 Spring Boot 应用程序,我曾经在 Eclipse 中使用过它在那里工作,最近切换到 IntelliJ,在 IntelliJ 应用程序中没有盯着,在这里我在启动时共享日志  .   ____          _            __ _ _ /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \ \\/  ___)| |_)| | | | | || (_| |  ) ) ) )  '  |____| .__|_| |_|_| |_\__, | / / / / =========|_|==============|___/=/_/_/_/ :: Spring Boot ::        (v2.0.0.RELEASE)2019-09-20 13:34:56.609  INFO 30977 --- [  restartedMain] com.kn.Application                       : Starting Application on Dhanu-MAC.local with PID 30977 (/Applications/Data/RT/20190815_source_prod/2_etn_backend/target/classes started by dhanu in /Applications/Data/RT/20190815_source_prod/2_etn_backend)2019-09-20 13:34:56.621  INFO 30977 --- [  restartedMain] com.kn.Application                       : The following profiles are active: devWARNING: An illegal reflective access operation has occurredWARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass (file:/Users/dhanu/.m2/repository/org/codehaus/groovy/groovy/2.4.13/groovy-2.4.13.jar) to method java.lang.Object.finalize()WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.reflection.CachedClassWARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operationsWARNING: All illegal access operations will be denied in a future release正如我在日志中看到的,它已成功与数据库连接,但 tomcat 停止了,没有显示任何原因我在这里呆了很长一段时间,有人可以帮忙吗?
查看完整描述

1 回答

?
白板的微信

TA贡献1883条经验 获得超3个赞

嵌套异常是java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlElement


简而言之:随着 Java 9 的发布,所需的依赖项已从 JDK 中删除。如果您使用 Java 8 JDK 启动应用程序,则会提供依赖项并且您的应用程序可以正常运行。如果您使用 Java 9 JDK 或更高版本启动应用程序,则依赖项将不再存在并且无法启动。

修复此问题的正确解决方案是将所需的依赖项添加到您的项目中:

dependencies {

    // JAX-B dependencies for JDK 9+

    implementation "javax.xml.bind:jaxb-api:2.2.11"

    implementation "com.sun.xml.bind:jaxb-core:2.2.11"

    implementation "com.sun.xml.bind:jaxb-impl:2.2.11"

    implementation "javax.activation:activation:1.1.1"

}

Maven 依赖项


<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->

        <dependency>

            <groupId>javax.xml.bind</groupId>

            <artifactId>jaxb-api</artifactId>

            <version>2.2.11</version>

        </dependency>

        <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core -->

        <dependency>

            <groupId>com.sun.xml.bind</groupId>

            <artifactId>jaxb-core</artifactId>

            <version>2.2.11</version>

        </dependency>

        <!-- https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-impl -->

        <dependency>

            <groupId>com.sun.xml.bind</groupId>

            <artifactId>jaxb-impl</artifactId>

            <version>2.2.11</version>

        </dependency>

        <!-- https://mvnrepository.com/artifact/javax.activation/activation -->

        <dependency>

            <groupId>javax.activation</groupId>

            <artifactId>activation</artifactId>

            <version>1.1.1</version>

        </dependency>


查看完整回答
反对 回复 2023-08-16
  • 1 回答
  • 0 关注
  • 80 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信