Spring Boot Application 无法从类路径启动:[]

我用jHipster生成了一个Spring Boot应用程序,从我以前的项目(非jhipster项目)中添加了一些代码,并尝试使用IDEA运行它。首先,我收到一条类似于此的错误消息,说“命令行太长..”(我运行的是 Windows 10 x64)。我单击了启用,但后来我得到了一个这样的错误:

"C:\Program Files\Java\jdk1.8.0_144\bin\java" -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:51351,suspend=y,server=n -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=51350 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true -Dfile.encoding=UTF-8 -classpath C:\Users\User\AppData\Local\Temp\classpath.jar com.test.pc.TestPartsComposerApp
Connected to the target VM, address: '127.0.0.1:51351', transport: 'socket'
The Class-Path manifest attribute in C:\Users\User\AppData\Local\Temp\classpath.jar referenced one or more files that do not exist: .... Extremely long list of jars
07:48:56.779 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
07:48:56.779 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
07:48:56.779 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : []

07:48:57.570 [restartedMain] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: []

在我尝试使用 .:/mvnw

The Class-Path manifest attribute in C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\jaxb-impl-2.2.3-1.jar referenced one or more files that do not exist: C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\jaxb-api.jar,C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\activation.jar,C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\jsr173_1.0_api.jar,C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl\2.2.3-1\jaxb1-impl.jar
The Class-Path manifest attribute in C:\Users\User\.m2\repository\org\liquibase\liquibase-core\3.5.3\liquibase-core-3.5.3.jar referenced one or more files that do not exist: C:\Users\User\.m2\repository\org\liquibase\liquibase-core\3.5.3\lib\snakeyaml-1.13.jar
07:53:54.295 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Included patterns for restart : []
07:53:54.295 [main] DEBUG org.springframework.boot.devtools.settings.DevToolsSettings - Excluded patterns for restart : [/spring-boot-starter/target/classes/, /spring-boot-autoconfigure/target/classes/, /spring-boot-starter-[\w-]+/, /spring-boot/target/classes/, /spring-boot-actuator/target/classes/, /spring-boot-devtools/target/classes/]
07:53:54.295 [main] DEBUG org.springframework.boot.devtools.restart.ChangeableUrls - Matching URLs for reloading : [file:/C:/workspace/jh-fpc/TestPartsComposer/target/classes/]
07:53:55.295 [restartedMain] DEBUG org.springframework.boot.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath: [file:/C:/workspace/jh-fpc/TestPartsComposer/target/classes/]

我在这里发布了我的。pom.xml

我创建了一个全新的项目,并开始逐个添加我拥有的maven依赖项,并在每个步骤后运行项目。类路径的问题发生了,当我将弹簧批次和番石榴添加到pom中时。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-batch</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>${guava-core.version}</version>
</dependency>

答案 1

我在jHipster应用程序中遇到了同样的问题,具有相同的错误消息,对我来说,我的根本原因是apprament-dev.yml中春季邮件设置的格式(缩进)错误。我只是从另一个项目复制/粘贴设置,IntelliJ将它们缩进得与原始代码中的设置略有不同,因此无法解决。

每次启动应用程序时都会出现这些“清单属性”,但至少对我来说,它们与真正的问题无关。希望这有助于找到事业的根源!干杯


答案 2

此错误消息由 ClasspathLoggingApplicationListener#onApplicationEvent 输出

但它没有输出错误的真正原因。

因此,您应该在调试模式下启动您的应用程序,并在此行添加断点,然后您可以检查,并找出真正发生的错误。event.exception

这个问题浪费了我大约30分钟....希望这个答案能为某人节省一点时间


推荐