Maven-无法加载类"org.slf4j.impl.StaticLoggerBinder"; [英] Maven - Failed to load class "org.slf4j.impl.StaticLoggerBinder"

查看:195
本文介绍了Maven-无法加载类"org.slf4j.impl.StaticLoggerBinder";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近在基于Windows的笔记本电脑上安装了Maven.但是在运行mvn只是为了测试我的安装时出现以下错误:

I have recently installed Maven on my windows based laptop. But getting following error when running mvn just to test my installation:

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.

无论何时运行mvn -version,我都会得到适当的响应:

Whoever when running mvn -version I am getting appropriate response:

Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T22:29:23+05:00)
Maven home: C:\apps\Maven
Java version: 1.7.0_25, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_25\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "x86", family: "windows"

请注意,在我的maven项目中运行mvn installmvn packagemvn clean或任何其他Maven目标时,我得到的错误完全相同,而项目对SLF4J没有任何依赖性.

Note that I am getting exactly same error when running mvn install, mvn package, mvn clean or any other Maven target in my maven project, while project doesn't have any dependency for SLF4J.

推荐答案

此错误通常表示您在类路径中有slf4j-api库,但没有与之关联的SLF4J binding.确保在类路径中的slf4j-api jar旁边有这些绑定jar中的一个(也请确保版本兼容):

This error usually means that you have the slf4j-api library in your classpath without an SLF4J binding associated with it. Make sure to have exactly one of these binding jars in your classpath alongside the slf4j-api jar (also make sure the versions are compatible):

  • slf4j-nop.jar,
  • slf4j-simple.jar,
  • slf4j-log4j12.jar,
  • slf4j-jdk14.jar或
  • logback-classic.jar

SLF4J在其常见问题"页面上列出了所有此类错误代码.您可以在此处找到该问题和解决方案.

The SLF4J lists all such error codes on its FAQ page. You can find this issue and resolution documented here.

IIRC,这只是一个警告,不会影响您的构建过程-还是吗?如果您不是真的想在类路径中包含SLF4J库,那么它们将被传递.使用mvn dependency:treem2eclipseDependency Hierarchy视图查找这些SLF4J相关库的源并将其排除.

IIRC, this is merely a warning and won't affect your build process - or does it? If you didn't really mean to include the SLF4J libraries in your classpath, they would have been pulled in transitively. Use the mvn dependency:tree or the m2eclipse's Dependency Hierarchy view to find the source of these the SLF4J related libraries and exclude them.

这篇关于Maven-无法加载类"org.slf4j.impl.StaticLoggerBinder";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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