1. 程式人生 > >Hibernate引入資料庫依賴包出現 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 問題

Hibernate引入資料庫依賴包出現 SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 問題

 

在學習SpringBoot時,有的時候明明專案執行起來沒有問題,但是Console控制檯會報錯 由此我們可以看出,報出錯誤的地方主要是slf4j的jar包,而故障碼中“Failed to load class ’org.slf4j.impl.StaticLoggerBinder‘”的意思則是“載入類檔案org.slf4j.impl.StaticLoggerBinder時失敗”。官網給出解釋:

This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

翻譯過來如下所示:

這個錯誤是當org.slf4j.impl報道。StaticLoggerBinder類不能被載入到記憶體中。發生這種情況時,無法找到合適的SLF4J繫結類路徑。slf4j-nop.jar放置一個(且只有一個), slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar 或 logback-classic.jar 的類路徑應該解決這個問題。

        所以說解決的辦法就是在Maven工程的pom檔案中隨便載入一個上述的包檔案之一的依賴就可以了(且只有一個),此時我載入的是“slf4j-nop-1.7.2.jar”包檔案的依賴,然後整個專案就可以編譯無異常通過了。

 

 

<dependency>
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-nop</artifactId>
        <version>1.7.2</version>
</dependency>

 

文章借鑑:https://www.cnblogs.com/justlove/p/7637681.html