Here are the exception details.
Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.slf4j.impl.StaticLoggerBinder.SINGLETON from class org.slf4j.LoggerFactory at org.slf4j.LoggerFactory.<clinit>(LoggerFactory.java:60)
This error is caused by the static initilizer of the LoggerFactory class attempting to directly access the SINGLETON field oforg.slf4j.impl.StaticLoggerBinder. While this was allowed in SLF4J 1.5.5 and earlier, in 1.5.6 and later the SINGLETON field has been marked as private access.
If you get the exception shown above, then you are using an older version of slf4j-api, e.g. 1.4.3, with a new version of a slf4j binding, e.g. 1.5.6. Typically, this occurs when your Maven pom.ml file incoprporates hibernate 3.3.0 which declares a dependency on slf4j-api version 1.4.2. If yourpom.xml declares a dependency on an slf4j binding, say slf4j-log4j12 version 1.5.6, then you will get illegal access errors.
To see which version of slfj4-api is pulled in by Maven, use the maven dependency plugin as follows.
mvn dependency:tree
If you are usig Eclipse, please do not rely on the dependency tree shown by m2eclipse.
In your pom.xml file, excplicitly declaring a dependecy on slf4j-api matching the version of the declared binding will make the problem go away.
本文介绍了一个关于SLF4J非法访问错误的问题,该问题发生在使用旧版slf4j-api与新版SLF4J绑定时。文章详细解释了错误产生的原因,并提供了检查依赖版本及解决此问题的方法。
4万+

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



