今天在运行代码时,有个报错,但是也不影响其他内容正常输出
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
报错原因就是没有找 StaticLoggerBinder 这个类
然后开始百度,找到了解决方法
1、先加入了这个依赖
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
运行之后还是报错,然后又看了一下其他的解决方案,原来是我的引入的依赖的范围scope需要调整下调整承compile
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>compile</scope>
</dependency>
重新运行,没有报错了
可以参考这个文章:https://blog.youkuaiyun.com/u010696630/article/details/84991116

在使用IntelliJ IDEA运行Java代码时遇到SLF4J报错,问题在于未能加载StaticLoggerBinder类。通过添加相应依赖并调整依赖范围为compile来解决此问题,参照了相关博客文章,重新运行后错误消除。
2万+

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



