Eclipse - 无法加载类“org.slf4j.impl.StaticLoggerBinder” [英] Eclipse - Failed to load class "org.slf4j.impl.StaticLoggerBinder"
问题描述
我正在使用 eclipse juno 使用 maven (m2eclipse插件)运行别人的Java代码。但是我收到以下消息:
I am using eclipse juno to run someone's else Java code using maven(m2eclipse plugin). But I am getting following message:
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.
在官方网站,我发现以下问题的修复:
On the official website, I found the following fix for this problem:
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-simple.jar在C:\Program Files\ Java\jdk1.7.0_07\lib即可。但是我仍然收到错误。
So I copied slf4j-simple.jar in "C:\Program Files\Java\jdk1.7.0_07\lib". But I am still getting error.
请指导我什么是正确的解决方案。我是一个Java新手。
Please guide me what is correct solution. I am a Java newbie.
还有人可以提到什么应该是 JAVA_HOME
, CLASSPATH
和 CLASS
变量。我感到困惑是否应该是路径 jre
或 jdk
或任何?
Also can someone please mention what exactly should be the value for JAVA_HOME
, CLASSPATH
and CLASS
variables. I am confused whether it should be path of jre
or jdk
or any?
更新:
依赖于 slf4j
项目 pom.xml
。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.5.6</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.5.6</version>
</dependency>
我已经更新了我的项目。另外, slf4j-api-1.5.6.jar
和 slf4j-simple-1.5.6.jar
正在显示在我的项目中的Maven依赖项中。而 org.slf4j.impl.StaticLoggerBinder.class
也存在于 slf4j-simple-1.5.6.jar
I have updated my project. Also the slf4j-api-1.5.6.jar
and slf4j-simple-1.5.6.jar
are showing up in "Maven dependencies" in my project. And org.slf4j.impl.StaticLoggerBinder.class
is also present in slf4j-simple-1.5.6.jar
推荐答案
使用捆绑的maven版本(m2e)时,Eclipse Juno,Indigo和Kepler不会抑制消息SLF4J:无法加载类org.slf4j.impl.StaticLoggerBinder。此行为存在于m2e版本1.1.0.20120530-0009及以后版本中。
Eclipse Juno, Indigo and Kepler when using the bundled maven version(m2e), are not suppressing the message SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". This behaviour is present from the m2e version 1.1.0.20120530-0009 and onwards.
尽管这表示为错误,您的日志将被正常保存。突出显示的错误仍然存在,直到有一个修复这个错误。有关 m2e支持网站的更多信息。
Although, this is indicated as an error your logs will be saved normally. The highlighted error will still be present until there is a fix of this bug. More about this in the m2e support site.
当前可用的解决方案是使用外部的maven版本而不是Eclipse的捆绑版本。您可以在下面的问题中找到有关此解决方案以及有关此错误的更多详细信息,我相信您将描述您遇到的同样的问题。
The current available solution is to use an external maven version rather than the bundled version of Eclipse. You can find about this solution and more details regarding this bug in the question below which i believe describes the same problem you are facing.
SLF4J:无法加载类org.slf4j.impl.StaticLoggerBinder。错误
这篇关于Eclipse - 无法加载类“org.slf4j.impl.StaticLoggerBinder”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!