Java,Maven:构建期间出现SLF4J错误

ksn*_*tum 6 java dependencies log4j slf4j maven

我正在研究Java项目并使用Maven(m2e)构建它.当我这样做时,我mvn clean install首先得到这个错误:

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.
Run Code Online (Sandbox Code Playgroud)

首先是日志记录看起来很好(这是非常基本的).但是我不喜欢构建中的错误所以我遵循了URL.它基本上说类可以在几个包中的一个中找到,所以我添加slf4j-simple到我的依赖项中.我不知道使用哪个版本,所以我得到了最新版本(1.7.1).错误没有消失.

似乎我的一个依赖项(JXL)需要log4j1.2.14版本,这就是需要的东西slf4j.我不认为我可以改变这个(我可以吗?).我的想法是,可能slf4j是错误的版本,但我不知道如何找出log4j需要的版本.

首先,我是否有问题?第二,即使我不这样做,有没有办法摆脱警告?

这是输出mvn dependency:tree:

[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ dpt ---
[INFO] com.nike.dpt:dpt:war:1.3-SNAPSHOT
[INFO] +- javax.servlet:jsp-api:jar:2.0:provided
[INFO] +- javax.servlet:servlet-api:jar:2.5:provided
[INFO] +- javax.servlet:jstl:jar:1.2:runtime
[INFO] +- net.sourceforge.jexcelapi:jxl:jar:2.6.12:compile
[INFO] |  \- log4j:log4j:jar:1.2.14:compile
[INFO] +- commons-dbcp:commons-dbcp:jar:1.4:compile
[INFO] |  \- commons-pool:commons-pool:jar:1.5.4:compile
[INFO] +- org.springframework:spring-core:jar:3.1.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-asm:jar:3.1.2.RELEASE:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- org.springframework:spring-tx:jar:3.1.2.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-aop:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-beans:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-aspects:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-context-support:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-jdbc:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:3.1.2.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:3.1.2.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-core:jar:3.1.0.RELEASE:compile
[INFO] |  \- org.springframework.security:spring-security-crypto:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:3.1.0.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-web:jar:3.1.0.RELEASE:compile
[INFO] +- com.vaadin:vaadin:jar:6.8.2:compile
[INFO] +- com.google.gwt:gwt-user:jar:2.4.0:provided
[INFO] |  +- javax.validation:validation-api:jar:1.0.0.GA:provided
[INFO] |  \- javax.validation:validation-api:jar:sources:1.0.0.GA:provided
[INFO] +- org.aspectj:aspectjrt:jar:1.7.0:compile
[INFO] +- org.aspectj:aspectjweaver:jar:1.7.0:compile
[INFO] +- junit:junit:jar:4.10:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.1:test
[INFO] +- org.mockito:mockito-all:jar:1.9.0:test
[INFO] +- cglib:cglib-nodep:jar:2.2.2:compile
[INFO] +- com.oracle:ojdbc14:jar:10.2.0.4.0:compile
[INFO] +- org.vaadin.addons:filteringtable:jar:0.5.3:compile
[INFO] +- org.vaadin.addons:popupbutton:jar:1.2.1:compile
[INFO] \- org.slf4j:slf4j-simple:jar:1.7.1:compile
[INFO]    \- org.slf4j:slf4j-api:jar:1.7.1:compile
Run Code Online (Sandbox Code Playgroud)

我使用Maven插件(m2e)在Eclipse(Juno)IDE中运行.我用于Maven的CLI是mvn clean package taomcat7:runmvn clean install tomcat7:run.当我从命令行调用Maven时,我没有看到slf4j错误,所以这可能与m2eEclipse或Eclipse设置有关.

小智 7

错误消息与您的项目无关.这是一个m2e问题,不会造成任何伤害.如果在Eclipse之外的命令行上构建,则不会看到它.

有一个关于这个的错误,但不幸的是他们更愿意混淆peole而不是解决它:

https://bugs.eclipse.org/bugs/show_bug.cgi?id=387064