SLF4J: Failed to load class "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.
大概意思:
StaticLoggerBinder類不能被加載到內存中。發生這種情況時,無法找到合適的SLF4J綁定類路徑。slf4j-nop.jar放置一個(且只有一個), slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar 或 logback-classic.jar 的類路徑應該解決這個問題。
解決方案:
在maven 中加入上述中的其中一個jar包的應用就可以解決問題, 我添加的是logback的。
<!-- slf4j -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!-- logback -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
重新運行結果, 成功打印log。