无法加载类“org.slf4j.impl.StaticLoggerBinder” java项目中的错误? [英] Failed to load class "org.slf4j.impl.StaticLoggerBinder" error in java project?

查看:110
本文介绍了无法加载类“org.slf4j.impl.StaticLoggerBinder” java项目中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到无法加载类org.slf4j.impl.StaticLoggerBinder error.I想要将记录器写入文件。所以我使用了log4j .jar和我正在使用apache tomcat服务器。

I'm getting Failed to load class "org.slf4j.impl.StaticLoggerBinder" error.I want to write the logger in to a file.so i used log4j.jar and am using apache tomcat server.

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.


推荐答案

首先。关于依赖关系。

为了添加SLF4J,你必须在你的 ONE 中加上 ONE 这些依赖关系pom.xml中。这取决于您选择使用的实现。您在pom.xml中添加的每个依赖项都会自动添加到类路径中。如果下面的依赖项之一由另一个依赖项提供,那么您可以省略它。不要忘记,即使依赖项是由另一个依赖项提供的,您也必须只包含一个。请注意,我已从依赖项中省略了该版本。使用最新的。

In order to add SLF4J you must put ONE and only ONE of these dependencies in your pom.xml. It depends on what implementation you choose to use. Every dependency you add in the pom.xml is added automatically in the classpath. If one of the below dependencies are provided by another dependency then you can omit it. Dont forget that you must include only one even if the dependency is provided by another dependency. Notice that i have omitted the version from the dependencies. Use the latest available.

<dependency>
   <groupId>ch.qos.logback</groupId>
   <artifactId>logback-classic</artifactId>
   <version></version>
</dependency>



<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-simple</artifactId>
   <version></version>
   <scope>compile</scope>
</dependency>



<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-log4j12</artifactId>
   <version></version>
   <scope>compile</scope>
</dependency>



<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-jdk14</artifactId>
   <version></version>
   <scope>compile</scope>
</dependency>

现在关于构建maven项目时遇到的恼人错误。如果只有上述依赖项中的一个后仍然得到SLF4J:无法加载类org.slf4j.impl.StaticLoggerBinder。然后你面临来自m2e的错误。

Now regarding the annoying error you are getting when building your maven project. If after having only one of the above dependencies you still get the SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". then you are facing a bug from m2e.

当使用捆绑的maven版本(m2e)时,Eclipse Juno和Indigo不会抑制消息SLF4J:无法加载类org.slf4j.impl.StaticLoggerBinder 。此行为存在于m2e版本1.1.0.20120530-0009及之后。

Eclipse Juno and Indigo, 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 think describes the same problem you are facing.

SLF4J:无法加载类org.slf4j.impl.StaticLoggerBinder。错误

这篇关于无法加载类“org.slf4j.impl.StaticLoggerBinder” java项目中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆