Hibernate slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFac
问题描述:学习Hibernate持久化技术时,使用hibernate-annotations-3.4.0.GA版本做实验,做好了程序和配置文件后,运行程序出现Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory错误。
问题原因:jar文件版本冲突
类 org.slf4j.impl.StaticLoggerBinder在slf4j-api 中是类的公有静态变量:
publicstaticfinalStaticLoggerBinderSINGLETON=newStaticLoggerBinder();
而在slf4j-log4j12(slf4j-nop.jar,slf4j-simple.jar,slf4j-log4j12.jar,slf4j-jdk14.jarorlogback-classic.jar其中之一)中确是私有变量:
private static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder(); |
解决方案:1.修改slf的源代码,将这个变量有私有改为公有,再打包,问题可解决。
2.(推荐)在类路径先将slf4j-api.jar 删除,再导入同版本的slf4j-api-1.5.6.jar 和slf4j-log4j12-1.5.6.jar ,问题可解决。
相关推荐
MrLiar 2020-04-27
MrLiar 2020-02-20
guicaizhou 2020-01-25
JavaWinner 2019-11-03
laiwanwanyihao 2019-09-07
Selier 2012-09-21
zhangyayun0 2019-06-30
jianghuchuanke 2019-06-29
haojing 2014-06-25
LemonSnm 2012-12-28
sysuqgy 2012-06-06
mygirlgod 2019-06-28
mmayanshuo 2012-03-05
lisacheni 2011-12-18
栖梧桐 2011-05-15
qingjiuquan 2019-06-27
systemxgl 2011-03-16
逆流而上的鲤鱼 2010-11-04