2012-11-20 30 views
39

可能重复:
SLF4J: Failed to load class org.slf4j.impl.StaticLoggerBinder error日食 - 无法加载类 “org.slf4j.impl.StaticLoggerBinder”

我使用日食JUNO使用运行某人的其他Java代码maven(m2eclipse插件)。但我得到以下信息:

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. 

official website,我发现这个问题,以下修补程序:

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“。但我仍然有错误。

请指导我什么是正确的解决方案。我是一个Java新手。

也可以有人请提一下究竟应该是什么值为JAVA_HOME,CLASSPATHCLASS变量。我很困惑它是否应该是jrejdk或任何路径?

UPDATE:

以下为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.jarslf4j-simple-1.5.6.jar显示在“Maven dependencies”在我的项目中。并且org.slf4j.impl.StaticLoggerBinder.class也存在于slf4j-simple-1.5.6.jar

+0

在mvn clean install过程中发生了什么? –

+0

只需添加一个依赖到pom.xml中: < - 语言:郎XML - > org.slf4j SLF4J-log4j12 1.6.1 cane

回答

37

的Eclipse朱诺,靛蓝和开普勒使用捆绑行家版本(M2E),不抑制消息SLF4J时:无法加载类“org.slf4j.impl.StaticLoggerBinder”。此行为在m2e 1.1.0.20120530-0009及之后的版本中提供。

虽然这表示为错误,您的日志将正常保存。突出显示的错误仍然存​​在,直到修复此错误。更多关于m2e support site的信息。

当前可用的解决方案是使用外部maven版本而不是捆绑版本的Eclipse。你可以在下面的问题中找到关于这个解决方案的更多细节,并且我相信这个问题描述了你面临的同样的问题。

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error

9

您是否更新了项目(右键单击项目“Maven”>“更新项目...”)?否则,你需要检查是否pom.xml包含了必要的SLF4J的依赖,如:

<dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>jcl-over-slf4j</artifactId> 
     <version>1.7.0</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.0</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-log4j12</artifactId> 
     <version>1.7.0</version> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>log4j</groupId> 
     <artifactId>log4j</artifactId> 
     <version>1.2.14</version> 
    </dependency> 
+1

我已经更新这个问题与'pom.xml'内容的细节有关。请看一看。 – amitsharma

+0

你如何开始你的申请? –

+0

通过点击运行 - > Maven Build – amitsharma

2

将jar文件中所需的位置后,您需要通过添加的jar文件右击

项目 - >属性 - > Java Build Path - > Libraries - > Add Jar。

+0

我也手动添加了它,但仍然是相同的错误 – amitsharma

相关问题