Java Spring Boot 应用程序无法以类路径启动:[]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46599698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring Boot Application failed to start with classpath: []
提问by szab.kel
I generated a Spring Boot application with jHipster, added some code from my previous project (non-jhipster project) and tried to run it using IDEA. First I got an error message similar to this, saying "Command line is too long.." (I am running Windows 10 x64). I clicked enable, but then I got an error like this.:
我使用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: []
After I tried with ./mvnw
:
在我尝试使用 . /mvnw
:
The Class-Path manifest attribute in C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl.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.3-1\jaxb-api.jar,C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl.2.3-1\activation.jar,C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl.2.3-1\jsr173_1.0_api.jar,C:\Users\User\.m2\repository\com\sun\xml\bind\jaxb-impl.2.3-1\jaxb1-impl.jar
The Class-Path manifest attribute in C:\Users\User\.m2\repository\org\liquibase\liquibase-core.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.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/]
I posted my pom.xml
here.
我在pom.xml
这里发布了我的。
I created a completely new project, and started adding the maven dependencies I had one by one and Ran the project after every step. The problem with the classpath occurs, when I add BOTHspring-batch and guava to the pom.
我创建了一个全新的项目,并开始一个一个添加我拥有的 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>
回答by koni123
I had this same problem in a jHipster application with the same error messages and for me the root cause for me was wrong formatting (indentation) of spring mail settings in application-dev.yml. I just copy/pasted the settings from another project and IntelliJ indented them a bit differently than they were in original code and because of that they could not be resolved.
我在具有相同错误消息的 jHipster 应用程序中遇到了同样的问题,对我来说,根本原因是 application-dev.yml 中 spring 邮件设置的格式错误(缩进)。我只是从另一个项目复制/粘贴设置,IntelliJ 缩进它们的方式与原始代码中的略有不同,因此无法解析。
Those "manifest attribute" things appear every time when starting the application but at least for me they were not related to the real issue. Hope this helps to get to the root of the cause! Cheers,
每次启动应用程序时都会出现那些“清单属性”的东西,但至少对我来说,它们与真正的问题无关。希望这有助于找到原因!干杯,
回答by Li Ying
This error message is output by ClasspathLoggingApplicationListener#onApplicationEvent
此错误消息由ClasspathLoggingApplicationListener#onApplicationEvent输出
But it does not output the real reason of the error.
但它不会输出错误的真正原因。
So, you should start your app in debug mode, and add a breakpoint at this line, then you can check event.exception
, and find out what is the real error happened.
所以,你应该在调试模式下启动你的应用程序,并在这一行添加一个断点,然后你可以检查event.exception
,并找出真正发生的错误。
This problem wasted me like 30 minutes.... Hope this answer can save someone a little time
这个问题浪费了我 30 分钟......希望这个答案可以节省一些时间
回答by Ewan
I had the same issue with jhipster @4.10.2
& the solution what I got is here,
我遇到了同样的问题jhipster @4.10.2
&我得到的解决方案在这里,
As @koni123 rightly said it is something to do with application-dev.yml
, when i compared this file with the previous file version found that "spring.jpa.hibernate.format_sql: true" was giving me issue. Once i removed it from application-dev.yml it resolved my problem. Hope this helps.
正如@koni123 正确地说它与application-dev.yml
,当我将此文件与以前的文件版本进行比较时发现“spring.jpa.hibernate.format_sql:true”给了我问题。一旦我从 application-dev.yml 中删除它,它就解决了我的问题。希望这可以帮助。
回答by Nu?ito de la Calzada
be sure that you have the CONSOLE appender active in you logger. That will tells you what the problem really is in the Eclipse console
确保您的记录器中的 CONSOLE appender 处于活动状态。这将告诉您 Eclipse 控制台中的真正问题是什么
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
回答by akuma8
Same issue, I just forgot to set spring.profiles.active
in application.properties and I have multiple application-*.properties
同样的问题,我只是忘了spring.profiles.active
在 application.properties 中设置,而且我有多个application-*.properties
回答by u11462130
Remove the dependency spring-boot-devtools
移除依赖 spring-boot-devtools
回答by Simon Dyson
I had the same problem with a JHipster(6.4.1) application, and following the suggestion of @koni123 I found that I had accidentally duplicated the XML declaration in logback-spring.xml
.
我在 JHipster(6.4.1) 应用程序中遇到了同样的问题,按照 @koni123 的建议,我发现我不小心在logback-spring.xml
.
After fixing the problem I can see that the manifest warning is still printed on startup, so this is just a red herring.
解决问题后,我可以看到清单警告仍然在启动时打印,所以这只是一个红鲱鱼。
回答by Sir Beethoven
I also had this problem in Spring, and it seems that the root cause was a conflicting SLF4J
dependency, which I had in my pom, with a different version from the one Spring uses natively.
我在 Spring 中也遇到了这个问题,似乎根本原因是SLF4J
我的 pom 中存在的冲突依赖,它与 Spring 本地使用的版本不同。