【问题标题】:Spring Boot project won't start from the VSCode terminal, but will start in the eclipse "Boot Dashboard" plugin [duplicate]Spring Boot项目不会从VSCode终端启动,而是会在eclipse“Boot Dashboard”插件中启动[重复]
【发布时间】:2021-01-29 21:34:45
【问题描述】:

我有一个后端 api spring boot 项目,当我尝试从 vscode bash 终端(eclipse bash 终端)启动它时,我收到以下错误:

10-15 07:38:37,212 org.springframework.context.support.AbstractApplicationContext:refresh WARN - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
10-15 07:38:37,212 org.apache.juli.logging.DirectJDKLog:log INFO - Stopping service [Tomcat]
10-15 07:38:37,227 org.springframework.boot.autoconfigure.logging.ConditionEvaluationReportLoggingListener:logMessage INFO -

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.

但是,当我使用 eclipse 插件:“Boot Dashboard”时,它工作正常并启动,没有错误....

我在终端中使用的命令是:

mvn clean install spring-boot:repackage
java -jar target/project-name-0.0.1-SNAPSHOT.jar

这曾经可以工作,然后有一天才开始抛出错误????。

我已经尝试过 maven 更新、项目清理、删除 /m2 文件夹、确保所有端口都已清除/打开、“将其关闭并再次打开” ????....无法从终端运行但是插件可以工作,不知道为什么。

【问题讨论】:

  • 你运行的是什么版本的java,stackoverflow.com/questions/43574426/…
  • 我使用的是 jdk 11
  • 如果您阅读我发布的链接,从 Java 9 和转发 JAXB 已从 jdk 中删除,因为它被认为是 Java EE 的一部分。如果要包含它,则需要使用标志 --add-modules java.xml.bind 进行编译
  • @ThomasAndolf 我可以点击您评论中的链接并将其添加到 pom 以解决我的问题:javax.xml.bind jaxb-api2.3.0 如果您想添加答案,我可以将其标记为正确...
  • 是的,确实如此...如果您想发布答案(而不是评论),我可以将其标记为正确答案...。

标签: java eclipse spring-boot visual-studio-code


【解决方案1】:

在 Eclipse 中,打开“调试”视图,右键单击代表 VM 可执行文件的树节点,然后打开其属性以查看所使用的整个命令行。

【讨论】:

    【解决方案2】:

    对于 Spring Boot 应用程序,最好使用 Spring Tool 套件或 Intellij。我的偏好将是 Intellij,因为我目前正在使用它。如果您正在使用 Angular 或 React 或任何其他前端库,请使用 Visual code studio 开始运行,然后使用听起来不错的 Intellij 启动 spring boot 应用程序,因为您可以轻松清除错误,因为 Intellij 是以这种方式设计的。

    【讨论】:

    • 我有 IntelliJ 的免费社区版本,我认为它可以工作吗?
    • 是的,即使我使用的是免费版本也可以
    猜你喜欢
    • 1970-01-01
    • 2014-03-27
    • 2018-05-30
    • 2020-12-29
    • 1970-01-01
    • 2017-01-09
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    相关资源
    最近更新 更多