前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >SLF4J: Failed to load class的问题及解决

SLF4J: Failed to load class的问题及解决

作者头像
卡尔曼和玻尔兹曼谁曼
发布2019-01-22 15:07:41
3.4K0
发布2019-01-22 15:07:41
举报

今天在用Maven搞一个工程,安装要求我添加了所有需要的依赖,可是一运行测试程序,就跳出这样一个大大的错误:

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”. SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Exception in thread “main” java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder ……

原来这是因为sl4j和log4j的不兼容导致的,具体处理方案如下: 首先看看你工程中的sl4j-api的版本(比如我的是1.5.11),然后在http://mvnrepository.com/搜索slf4j-log4j12,会出现SLF4J LOG4J 12 Binding,点击进入,会有很多版本的slf4j-log4j12,我们点击1.5.11版本的slf4j-log4j12进入详细信息页面,查看依赖的log4j,这个版本的slf4j-log4j12依赖的是1.2.14版本的log4j。

所以,我们在我们的工程中添加1.5.11版本的slf4j-log4j12和1.2.14版本的log4j,问题完美解决。

我发现这篇文章比我讲的清楚,请参考: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.

如果这样就修改了以后还是会报错,将SLF4J换成高版本试试!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2015年05月20日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档