簡體   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