繁体   English   中英

Spring Boot 应用程序无法以类路径启动:[]

[英]Spring Boot Application failed to start with classpath: []

我用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 依赖项,并在每一步之后运行该项目。 当我将两个spring-batch 和番石榴添加到 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>

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

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

此错误消息由ClasspathLoggingApplicationListener#onApplicationEvent输出

但它不会输出错误的真正原因。

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

这个问题浪费了我 30 分钟......希望这个答案可以节省一些时间

同样的问题,我只是忘了在 application.properties 中设置spring.profiles.active并且我有多个application-*.properties

删除依赖spring-boot-devtools

我在 JHipster(6.4.1) 应用程序中遇到了同样的问题,按照 @koni123 的建议,我发现我不小心复制了logback-spring.xml的 XML 声明。

解决问题后,我可以看到清单警告仍然在启动时打印,所以这只是一个红鲱鱼。

我在 Spring 中也遇到了这个问题,似乎根本原因是SLF4J依赖冲突,我在我的 pom 中使用了与 Spring 本地使用的版本不同的版本。

我在jhipster @4.10.2遇到了同样的问题,我得到解决方案在这里

正如@koni123 正确地说它与application-dev.yml ,当我将此文件与以前的文件版本进行比较时,发现“spring.jpa.hibernate.format_sql: true”给了我问题。 一旦我从 application-dev.yml 中删除它,它就解决了我的问题。 希望这会有所帮助。

确保您的记录器中的 CONSOLE appender 处于活动状态。 这将告诉您 Eclipse 控制台中的真正问题是什么

<root level="info">
        <appender-ref ref="CONSOLE" /> 
        <appender-ref ref="FILE" />
</root>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM