我正在嘗試運行Spring Boot入門示例。 https://spring.io/guides/gs/spring-boot/。 我真的很喜歡這個框架,但下面的問題真的很令人沮喪。Spring Boot演示未運行
我的pom.xml是完全一樣在演示
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
堆棧跟蹤
Exception in thread "main" java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
at org.apache.commons.logging.impl.SLF4JLocationAwareLog.warn(SLF4JLocationAwareLog.java:179)
at org.springframework.boot.SpringApplicationRunListeners.callFinishedListener(SpringApplicationRunListeners.java:91)
at org.springframework.boot.SpringApplicationRunListeners.finished(SpringApplicationRunListeners.java:72)
at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:810)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:324)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174)
at com.testing.Application.main(Application.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
,並在項目中唯一的類上市:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
System.out.println("Hello, world!");
SpringApplication.run(Application.class, args);
}
}
最後 a screenshot of the Libraries IntelliJ is listing
我正在使用內置於maven 3.0.5的IntelliJ Ultimate 2016.2。 我已經運行maven clean,刪除了.m2並獲得了新的repo,卸載了IntelliJ以及更多。請不要說它是「日誌框架不兼容」;我已經嘗試了幾乎每個SO提到,沒有運氣。
更新:建議,我直接從GitHub克隆項目,並嘗試使用spring-boot:run插件運行。仍然是例外。我完全喪失工作力,我不知道如何着手。
UPDATE: MVN依賴的結果是:樹--debug
constituent[0]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aether- api-1.0.2.v20150114.jar
constituent[1]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aether- connector-basic-1.0.2.v20150114.jar
constituent[2]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aether-impl- 1.0.2.v20150114.jar
constituent[3]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aether-spi-1.0.2.v20150114.jar
constituent[4]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aether-transport-wagon-1.0.2.v20150114.jar
constituent[5]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aether-util-1.0.2.v20150114.jar
constituent[6]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/aopalliance-1.0.jar
constituent[7]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/cdi-api-1.0.jar
constituent[8]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/commons-cli-1.2.jar
constituent[9]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/commons-io-2.2.jar
constituent[10]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/commons-lang-2.6.jar
constituent[11]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/commons-lang3-3.4.jar
constituent[12]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/guava-18.0.jar
constituent[13]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/guice-4.0-no_aop.jar
constituent[14]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/javax.inject-1.jar
constituent[15]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/jsoup-1.7.2.jar
constituent[16]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/jsr250-api-1.0.jar
constituent[17]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-aether-provider-3.3.9.jar
constituent[18]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-artifact-3.3.9.jar
constituent[19]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-builder-support-3.3.9.jar
constituent[20]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-compat-3.3.9.jar
constituent[21]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-core-3.3.9.jar
constituent[22]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-embedder-3.3.9.jar
constituent[23]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-model-3.3.9.jar
constituent[24]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-model-builder-3.3.9.jar
constituent[25]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-plugin-api-3.3.9.jar
constituent[26]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-repository-metadata-3.3.9.jar
constituent[27]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-settings-3.3.9.jar
constituent[28]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/maven-settings-builder-3.3.9.jar
constituent[29]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/org.eclipse.sisu.inject-0.3.2.jar
constituent[30]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/org.eclipse.sisu.plexus-0.3.2.jar
constituent[31]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/plexus-cipher-1.7.jar
constituent[32]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/plexus-component-annotations-1.6.jar
constituent[33]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/plexus-interpolation-1.21.jar
constituent[34]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/plexus-sec-dispatcher-1.3.jar
constituent[35]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/plexus-utils-3.0.22.jar
constituent[36]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/slf4j-api-1.7.5.jar
constituent[37]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/slf4j-simple-1.7.5.jar
constituent[38]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/wagon-file-2.10.jar
constituent[39]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/wagon-http-2.10-shaded.jar
constituent[40]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/wagon-http-shared-2.10.jar
constituent[41]: file:/usr/local/Cellar/maven/3.3.9/libexec/lib/wagon-provider-api-2.10.jar
constituent[42]: file:/usr/local/Cellar/maven/3.3.9/libexec/conf/logging/
到目前爲止,這兩個答案都聽起來像Spring Boot依賴管理問題,我很難相信基於對其進行的測試。這聽起來像是與項目相關的IntelliJ IDE問題。我恨你不得不修改你的項目來支持你的IDE。去安裝IntelliJ,看看發生了什麼。 –
步驟我把... 1)安裝的IntelliJ終極2016年2月1日 2)在項目的開始屏幕選擇了克隆創建基礎上,'/ complete'目錄從回購 項目中的入門回購 3) 4)用'spring-boot:run'創建maven運行配置文件5)Ran項目併成功運行。 我檢查了我的項目依賴關係與您的項目相比,我還有更多。我猜你已經通過網頁手動創建了你的項目?嘗試使用'complete'項目開始驗證它是否工作。然後需要回去看看你做了什麼不同於完整的。 –
你如何運行應用程序?你將它作爲Java應用程序,Spring啓動應用程序運行還是使用Maven?我使用相同版本的IntelliJ,使用相同的代碼,具有相同的庫列表,我可以完美地運行該應用程序。 – g00glen00b