2017-07-07 35 views
0

我正在學習使用STS的Spring Boot並遵循關於Udemy的教程。嘗試以Java應用程序的形式運行應用程序時出現以下錯誤。我看了其他類似的帖子,似乎沒有什麼新東西。大部分問題來自3 - 5年前。我試圖在我的POM中放置一些依賴項,但它給了我比我開始時更多的錯誤,所以我刪除了它們。以Java應用程序運行時彈出工具套件錯誤

的錯誤是: 無法加載類 「org.slf4j.impl.StaticLoggerBinder」

這裏是我的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 
<groupId>com.in28minutes.springboot</groupId> 
<artifactId>first-springboot-project</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.4.0.RELEASE</version> 
</parent> 

<properties> 
    <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> 
</project> 

這裏是我試圖運行:

package com.in28minutes.springboot; 

import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.context.ApplicationContext; 

@SpringBootApplication 
public class Application { 

public static void main(String[] args) { 
    ApplicationContext ctx = SpringApplication.run(Application.class, 
    args); 

    } 

} 

有沒有人有建議,我可以做些什麼來解決這個問題?我綁定?原來的示例代碼可以在這裏找到在教練的回購:https://github.com/in28minutes/SpringBootForBeginners/blob/master/Step01.md

+1

哪裏出錯? – danieljohngomez

+0

它需要作爲彈簧啓動應用程序運行。不是Java應用程序。春季容器做了很多特定的東西。 – efekctive

+0

我想也許是教練在視頻中的錯誤,所以我嘗試了。如果我嘗試將其作爲彈簧引導應用程序運行,則會出現相同的錯誤。 –

回答

0

我不是用STS但是從這個docs下你應該運行你的應用程序作爲春季啓動應用程序因爲你使用Spring啓動。 但你的錯誤似乎是因爲依賴錯誤,如果你熟悉命令行我建議你在運行你的Spring項目之前執行mvn clean install以確保所有依賴項都被下載。

另一個提示,如果你對命令行有好處試着在你的項目目錄下執行mvn spring-boot:run它會執行你的Spring項目。