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

vjrehmav  于 2023-02-07  发布在  Java
关注(0)|答案(9)|浏览(177)

我用jHipster生成了一个Sping Boot 应用程序,添加了我以前的项目(非jhipster项目)中的一些代码,并尝试使用IDEA运行它。首先,我得到了一个类似this的错误消息,说“命令行太长..”(我运行的是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.xmlhere
我创建了一个全新的项目,并开始逐一添加我的maven依赖项,并在每一步之后运行该项目。当我将BOTHspring-batch和guava添加到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>
hwazgwia

hwazgwia1#

我在一个jHipster应用程序中遇到了同样的问题,并显示了同样的错误消息,对我来说,根本原因是application-dev. yml中的spring mail设置格式错误(缩进)。我只是从另一个项目中复制/粘贴了设置,IntelliJ将其缩进为与原始代码中的设置稍有不同,因此无法解决这些问题。
那些“清单属性”的东西在每次启动应用程序时都会出现,但至少对我来说,它们与真实的的问题无关。希望这有助于找到问题的根源!干杯,

lp0sw83n

lp0sw83n2#

此错误消息由类路径日志记录应用程序侦听器#onApplicationEvent输出
但它不输出错误的真实的原因。
因此,您应该在调试模式下启动应用,并在此行添加断点,然后您可以检查event.exception,并找出真实的发生的错误。
这个问题浪费了我大约30分钟....希望这个答案能为某人节省一点时间

shyt4zoc

shyt4zoc3#

同样的问题,我只是忘了在www.example.com中设置spring.profiles.activeapplication.properties,而我有多个application-*.properties

muk1a3rh

muk1a3rh4#

删除依赖项spring-boot-devtools

k97glaaz

k97glaaz5#

我在使用JHipster(6.4.1)应用程序时遇到了同样的问题,在@koni123的建议下,我发现我不小心复制了logback-spring.xml中的XML声明。
在修复了这个问题之后,我可以看到清单警告仍然在启动时打印,所以这只是一个转移注意力的问题。

rpppsulh

rpppsulh6#

我在Spring中也遇到过这个问题,看起来根本原因是一个冲突的SLF4J依赖项,我在pom中有这个依赖项,它的版本与Spring本地使用的版本不同。

jfgube3f

jfgube3f7#

检查Main.class路径:enter image description here
您的Main.class需要在自定义包中。如果在您的Main.class中不包含条目“package ...",您将得到一个错误。

hmmo2u0o

hmmo2u0o8#

我在使用jhipster @4.10.2时遇到了同样的问题&我得到的解决方案就在这里
正如@koni123正确地说,这是一些与application-dev.yml,当我比较这个文件与以前的文件版本发现,“spring.jpa.hibernate.format_sql:真”给我的问题。一旦我从application-dev.yml中删除它,它解决了我的问题。希望这能有所帮助。

xn1cxnb4

xn1cxnb49#

确保在日志记录器中激活了CONSOLE附加器,这将告诉您Eclipse控制台中真正的问题是什么

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

相关问题