有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

JavaSpring引导项目不会从VSCode终端启动,而是在eclipse“引导仪表板”插件中启动

我有一个后端api spring引导项目,当我尝试从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插件:“引导仪表板”时,它工作正常,并且启动时没有错误

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

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

这曾经是有效的,然后有一天刚刚开始抛出错误😕.

我尝试过maven更新、project清理、删除/m2文件夹、确保所有端口都已清除/打开,“关闭并再次打开”🤷.... 从终端不工作,但从插件工作,不知道为什么


共 (2) 个答案

  1. # 1 楼答案

    在Eclipse中,打开Debug视图,右键单击表示VM可执行文件的树节点,并打开其属性以查看所使用的整个命令行

  2. # 2 楼答案

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