SLF4J 报错解决方法
使用Shiro,官网给的代码,出现报错
运行Maven项目时,控制台出现如下图所示的报错信息:
在网上搜到,内容大致如下:
问题的原因是无法找到org.slf4j.impl.StaticLoggerBinder,我找了一下,确实没有该类,网上搜了一下下面是官方的解答http://www.slf4j.org/codes.html#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.
You can download SLF4J bindings from the project download page.
翻译:
此错误在组织slf4j.inf.strestcoperbinder类无法装入内存时报告。当在类路径上找不到合适的slf4j绑定时,就会发生这种情况。slf4j-nop.jar放置一个(且只有一个), slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar 或 logback-classic.jar 的类路径应该解决这个问题。
我的解决方案:
在Maven工程的pom文件中,新增一个依赖 slf4j-nop.jar,就解决问题了
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.2</version>
</dependency>