java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory

错误记录:java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory

同事咨询一个异常,我搜了一下,发现了stackoverflow上的一个回答:

This problem is due to a change in slf4j-log4j12 jar. From version 1.5.6 it doesn't allow to access the field org.slf4j.impl.StaticLoggerBinder.SINGLETON.
To resolve it, use the newest jars (or at least version 1.5.6 onward) for both slf4j-api & slf4j-log4j12.

这里说的是slf4j-log4j12的版本问题,需要将slf4j-api,slf4j-log4j12升级到1.5.6+的版本。

我右键项目pom文件,用Eclipse Pom Editer打开。点到Dependency Hierarchy界面,在Filter框中搜索slf4j,得到了关于slf4j的依赖树,发现内部项目的某个模块使用了hibernate3.x,而这个hibernate依赖了slf4j1.4.2的版本。

果然这个版本太低了,于是增加了如下依赖:

<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>1.7.5</version>
</dependency>
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-log4j12</artifactId>
  <version>1.7.5</version>
</dependency>

问题解决。

posted @ 2017-04-25 14:33  逃离沙漠  阅读(1110)  评论(0编辑  收藏  举报