eclipse SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder”。错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11916706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". error
提问by Konstantinos Margaritis
- Regarding Eclipse IDE(Indigo, Junoand Kepler(32 and 64 bit versions))
- Platforms: Windows, Ubuntu, Mac
- m2e version: 1.1.0.20120530-0009, 1.2.0.20120903-1050, 1.3.0.20130129-0926,
1.4.0.20130601-0317
- 关于Eclipse IDE(Indigo、Juno和Kepler(32 位和 64 位版本))
- 平台:Windows、Ubuntu、Mac
- M2E版本:1.1.0.20120530-0009,1.2.0.20120903-1050,1.3.0.20130129-0926,
1.4.0.20130601-0317
General info
基本信息
The above error came after updating the m2e to version 1.1. By removing m2e 1.1 and rolling back to m2e 1.0 everything worked fine.I tried to repeat the problem in Windows and Ubuntu and it gave me the exact same error. Numerous configurations of the slf4j-api and logback were tested but none seem to work.
将 m2e 更新到 1.1 版后出现上述错误。通过删除 m2e 1.1 并回滚到 m2e 1.0,一切正常。我试图在 Windows 和 Ubuntu 中重复这个问题,它给了我完全相同的错误。测试了 slf4j-api 和 logback 的许多配置,但似乎都不起作用。
The error appears in any maven project even without declaring slf4j dependency.
即使没有声明 slf4j dependency ,该错误也会出现在任何 maven 项目中。
New Maven Project--> maven-archetype-quickstart
and
New Maven Project--> Simple project without archetype selection
result to
新建 Maven 项目--> maven-archetype-quickstart
和
新建Maven项目-->没有原型选择的简单项目
结果到
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
Testing enviroments and configurations
测试环境和配置
Tested with Eclipse Indigo and Eclipse Juno (32 and 64 bit both) on Mac, 32 bit on Ubuntu and 64 and 32 bit on Windows. Tested fresh installs of Juno Classic, Juno Modelling tools, Kepler Standard, Kepler Modelling Toolsand produced the same error.
在 Mac 上使用 Eclipse Indigo 和 Eclipse Juno(32 位和 64 位)进行测试,在 Ubuntu 上使用 32 位,在 Windows 上使用 64 位和 32 位进行测试。测试了Juno Classic、Juno Modeling tools、Kepler Standard、Kepler Modeling Tools 的全新安装并产生了相同的错误。
The error appears with clean, install, test, deploy, generate-sources, validate, compile, package, integration-test, verifyand combinations of the goal clean with the rest goals. It appears also with parameters -eand -X. There was an attempt to delete the m2e repository and download it from scratch but again without success. It should me mentioned that it was tested in 3 different machines and virtual box all the above systems but it produced the same error.
错误出现在clean、install、test、deploy、generate-sources、validate、compile、package、integration-test、verify以及 clean 目标与其余目标的组合。它也与参数-e和-X一起出现。曾尝试删除 m2e 存储库并从头开始下载,但再次没有成功。我应该提到它在 3 台不同的机器和所有上述系统的虚拟机中进行了测试,但它产生了相同的错误。
Tried all different logbackconfigurations (from 1.0.4 to 1.0.13) that resolve the slf4j-apiand logback-coredependencies, but all produce the same error:
尝试了解决slf4j-api和logback-core依赖项的所有不同的logback配置(从 1.0.4 到 1.0.13),但都产生相同的错误:
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version></version>
</dependency>
Tried all different (from 1.6.1 to 1.7.5 ) slf4j-simpleconfigurations.
尝试了所有不同的(从 1.6.1 到 1.7.5 )slf4j-simple配置。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Tried all different (from 1.6.1 to 1.7.5 ) log4j-over-slf4jconfigurations.
尝试了所有不同的(从 1.6.1 到 1.7.5 )log4j-over-slf4j配置。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Tried all different (from 1.6.1 to 1.7.5 ) slf4j-jdk14configurations.
尝试了所有不同的(从 1.6.1 到 1.7.5 )slf4j-jdk14配置。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Tried all different (from 1.6.1 to 1.7.5 ) slf4j-log4j12configurations.
尝试了所有不同的(从 1.6.1 到 1.7.5 )slf4j-log4j12配置。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version></version>
<scope>compile</scope>
</dependency>
Tried slf4j-nop 1.7.5configuration.
试过slf4j-nop 1.7.5配置。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.7.5</version>
<scope>compile</scope>
</dependency>
Last but not least the logs are saved and printed despite the error.
最后但并非最不重要的一点是,尽管出现错误,日志仍会被保存和打印。
Ways to reproduce the error
重现错误的方法
Download Eclipse Juno, Indigo or Kepler 32 or 64 bit (All installations will cause the same error).
Install m2e - Maven Integration for Eclipse
- Juno - http://download.eclipse.org/releases/juno
- Kepler - http://download.eclipse.org/releases/kepler
- Indigo - http://download.eclipse.org/technology/m2e/releases/(currently unavailable)
OR
Update your m2e version to 1.1.0.20120530-0009, or 1.2.0.20120903-1050, or 1.3.0.20130129-0926, or 1.4.0.20130601-0317)
Select File->New->Other->Maven Project->Click Next->Select
maven-archetype-quickstart from the catalog->FinishOR
Select File->New->Other->Maven Project->Click Next->Select Create a simple project (skip archetype selection)-> Complete Artifact info-> Finish
- Right Click on the project->Runs As->clean install (or any other goal mentioned above)
下载 Eclipse Juno、Indigo 或 Kepler 32 或 64 位(所有安装都会导致相同的错误)。
安装 m2e - Eclipse 的 Maven 集成
- 朱诺 - http://download.eclipse.org/releases/juno
- 开普勒 - http://download.eclipse.org/releases/kepler
- Indigo - http://download.eclipse.org/technology/m2e/releases/(目前不可用)
或者
将您的m2e版本更新为1.1.0.20120530-0009或1.2.0.20120903-1050或1.3.0.20130129-0926或1.4.0.20130601-0317)
选择File->New->Other->Maven Project->点击Next->从目录中选择
maven-archetype-quickstart->Finish或者
选择File->New->Other->Maven Project->点击Next->选择Create a simple project(跳过archetype选择)-> Complete Artifact info->Finish
- 右键单击项目-> 运行方式-> 全新安装(或上述任何其他目标)
The first line on the console will be
控制台上的第一行将是
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.
P.S. Existing projects will produce the same error after updating the m2e version to 1.1.0.20120530-0009, 1.2.0.20120903-1050, 1.3.0.20130129-0926, 1.4.0.20130601-0317
PS 现有项目将 m2e 版本更新为 1.1.0.20120530-0009,1.2.0.20120903-1050,1.3.0.20130129-0926,1.4.0.201031609后会产生同样的错误
Updates
更新
EDIT
编辑
m2e support site:
m2e 支持站点:
The above question was posted as a bug in m2e support site and the answer from Igor Fedorenko was that
There are no immediate plans to suppress this message.
For viewing the above bug please refer to m2e official support site
上述问题作为 m2e 支持站点的错误发布,Igor Fedorenko 的回答是
没有立即计划取消此消息。
要查看上述错误,请参阅m2e 官方支持站点
EDIT 2编辑 2
- The above error indication is presentalso to m2eversion 1.2.0.20120903-1050
- 上述误差指示是本也M2E版本1.2.0.20120903-1050
EDIT 3编辑 3
- The above error indication is presentalso to m2eversion 1.3.0.20130129-0926
- 上述误差指示是本也M2E版本1.3.0.20130129-0926
EDIT 4编辑 4
- The above error indication is presentalso to m2eversion 1.4.0.20130601-0317
- 上述误差指示是本也M2E版本1.4.0.20130601-0317
EDIT 5编辑 5
***Reported FIXED***
- The above error is reported as fixed for m2eversion 1.5.0/Luna M3(Target Milestone). The version is not yet available for download.
- Luna M3is scheduled for Nov. 15th.
- Latest dev build are available here
- More information about the m2e milestones you can find at the m2e main repository.
采纳答案by tverrbjelke
I can also confirm this error.
我也可以确认这个错误。
Workaround:is to use external maveninside m2eclipse, instead of it's embedded maven.
解决方法:是在 m2eclipse 中使用外部 maven,而不是它的嵌入式 maven。
That is done in three steps:
这是分三步完成的:
1 Install maven on local machine(the test-machine was Ubuntu 10.10)
1 在本地机器上安装maven(测试机器是Ubuntu 10.10)
mvn --version
Apache Maven 2.2.1 (rdebian-4) Java version: 1.6.0_20 Java home: /usr/lib/jvm/java-6-openjdk/jre Default locale: de_DE, platform encoding: UTF-8 OS name: "linux" version: "2.6.35-32-generic" arch: "amd64" Family: "unix"
mvn --version
Apache Maven 2.2.1 (rdebian-4) Java 版本:1.6.0_20 Java 主页:/usr/lib/jvm/java-6-openjdk/jre 默认语言环境:de_DE,平台编码:UTF-8 操作系统名称:“linux”版本:“2.6.35-32-generic”arch:“amd64”系列:“unix”
2 Run maven externally link how to run maven from console
2 运行 maven 外部 链接如何从控制台运行 maven
> cd path-to-pom.xml > mvn test
> cd path-to-pom.xml > mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Simple
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[...]
[INFO] Surefire report directory: [...]/workspace/Simple/target/surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.tverrbjelke.experiment.MainAppTest
Hello World
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.042 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[...]
3 inside m2eclipse: switch from embedded mavento local maven
3 m2eclipse内:从嵌入式maven切换到本地maven
- find out where local maven home installation dir is (
mvn --version
, or google for yourMAVEN_HOME
, for me this helped methat is/usr/share/maven2
) - in eclipse Menu->Window->Preferences->Maven->Installation-> enter that string. Then you should have switched to your new external maven.
- then run your Project as e.g. "maven test".
- 找出本地 maven home 安装目录的位置(
mvn --version
或谷歌搜索你的MAVEN_HOME
,对我来说这对我有帮助/usr/share/maven2
) - 在 Eclipse Menu->Window->Preferences->Maven->Installation-> 输入该字符串。那么您应该已经切换到新的外部 maven。
- 然后将您的项目运行为例如“maven test”。
The error-message should be gone.
错误消息应该消失了。
回答by Mohammed Irfan Tirupattur
There is a documentation in SLf4J site to resolve this. I followed that and added slf4j-simple-1.6.1.jar to my aplication along with slf4j-api-1.6.1.jar which i already had.This solved my problem
SLf4J 站点中有一个文档可以解决这个问题。我遵循了这一点,并将 slf4j-simple-1.6.1.jar 与我已经拥有的 slf4j-api-1.6.1.jar 一起添加到我的应用程序中。这解决了我的问题
回答by Dias
If you are using Gradle add this:
如果您使用 Gradle,请添加以下内容:
dependencies {
...
compile "org.slf4j:slf4j-simple:1.7.9"
...
}
回答by tomasb
Had similar error with the same result with Gradle and was able to solve it by following:
与 Gradle 有类似的错误和相同的结果,并能够通过以下方式解决它:
//compile 'org.slf4j:slf4j-api:1.7.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.1'
Out-commented line is the one which caused the error output. I believe you can transfer this to Maven.
Out-commented 行是导致错误输出的行。我相信您可以将其转移到 Maven。
回答by james25
Paste this code to your pom.xml file. It works for me.
将此代码粘贴到您的 pom.xml 文件中。这个对我有用。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
回答by khan
You haven't specify version in your maven dependency file may be thats why it is not picking the latest jar
As well as you need another deppendency with slf4j-log4j12
artifact id.
Include this in your pom file
您没有在 Maven 依赖文件中指定版本可能就是为什么它没有选择最新的 jar
以及您需要另一个具有slf4j-log4j12
工件 ID 的依赖关系。
将此包含在您的 pom 文件中
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
Let me know if error is still not resolved
I also recomend you to see this link
如果错误仍未解决,请
告诉我我也建议您查看此链接
回答by Prince
Had been over looking the issue having surfaced it. Believe this will be a good read for others who come down here with the same issue:
一直在寻找已经浮出水面的问题。相信对于遇到同样问题的其他人来说,这将是一本很好的读物:
回答by Vipul Agarwal
I had the similar issue for my Spring Boot - Gradle application running on Eclipse Luna. I could resolve it by manually adding an entry in my project's .classpath
我的 Spring Boot - 在 Eclipse Luna 上运行的 Gradle 应用程序也遇到了类似的问题。我可以通过在我的项目的 .classpath 中手动添加一个条目来解决它
<classpathentry sourcepath="C:/Users/<username>/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.7/3150039466ad03e6ef1c7ec1c2cbb0d96710cf64/slf4j-simple-1.7.7-sources.jar" kind="lib" path="C:/Users/<username>/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.7.7/8095d0b9f7e0a9cd79a663c740e0f8fb31d0e2c8/slf4j-simple-1.7.7.jar"/>
Idea is to follow thissolution. But how to implement is dependent on case to case. One way of fixing is the one that I used above.
想法是遵循这个解决方案。但如何实施取决于具体情况。一种修复方法是我上面使用的一种。
Hope this helps.
希望这可以帮助。
回答by avenugopalan
This is not an error message but a warning. It is very clearly explained in their website as :
这不是错误消息而是警告。在他们的网站上非常清楚地解释为:
This warning, i.e. not an error, message is reported when no SLF4J providers 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. Note that these providers must target slf4j-api 1.8 or later.
当在类路径上找不到 SLF4J 提供程序时,将报告此警告(即不是错误)消息。将 slf4j-nop.jar、slf4j-simple.jar、slf4j-log4j12.jar、slf4j-jdk14.jar 或 logback-classic.jar 中的一个(并且只有一个)放在类路径上应该可以解决问题。请注意,这些提供程序必须针对 slf4j-api 1.8 或更高版本。
In the absence of a provider, SLF4J will default to a no-operation (NOP) logger provider.
在没有提供者的情况下,SLF4J 将默认为无操作 (NOP) 记录器提供者。
回答by svk 041994
I had the same problem in writing the Kafka producer program using java. This error is coming due to the wrong slf4j library. use below slf4j-simple maven dependency that will fix your problem.
我在使用 java 编写 Kafka 生产者程序时遇到了同样的问题。由于错误的 slf4j 库而出现此错误。使用下面的 slf4j-simple maven 依赖项可以解决您的问题。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>