一、问题
Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
二、问题分析
slf4j是日志打印的工具类,只在pom.xml中添加了依赖配置。错误说是加载“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.
简单的说就是没有slf4j-nop.jar的jar.
三、问题解决
添加slf4j-nop.jar依赖:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.6.1</version>
</dependency>
具体版本后,请根据自己项目的依赖版本而定,保持一致!
本文解决了一个常见的编程问题,即在使用SLF4J日志框架时遇到的“Failed to load class 'org.slf4j.impl.StaticLoggerBinder'”错误。详细分析了错误原因,并提供了解决方案,通过在项目中正确添加slf4j-nop.jar依赖,确保日志框架正常工作。
2万+

被折叠的 条评论
为什么被折叠?



