SLF4J:找不到所需的log4j版本,但是在pom中

时间:2016-08-31 11:05:30

标签: java maven log4j slf4j

使用Eclipse Aether,我收到以下错误:

SLF4J:此版本的SLF4J需要log4j 1.2.12或更高版本。另请参阅http://www.slf4j.org/codes.html#log4j_version

在我的Maven依赖树中,我显然有log4j 1.2.14(最后一行):

de.continentale.spu:rrep-pjava-deployer:jar:1.0.0-SNAPSHOT
+- org.slf4j:slf4j-log4j12:jar:1.7.9:compile
|  \- org.slf4j:slf4j-api:jar:1.7.9:compile
+- junit:junit:jar:4.11:test
|  \- org.hamcrest:hamcrest-core:jar:1.3:test
+- org.eclipse.aether:aether-impl:jar:1.1.0:compile
|  +- org.eclipse.aether:aether-api:jar:1.1.0:compile
|  +- org.eclipse.aether:aether-spi:jar:1.1.0:compile
|  \- org.eclipse.aether:aether-util:jar:1.1.0:compile
+- org.eclipse.aether:aether-connector-basic:jar:1.1.0:compile
+- org.eclipse.aether:aether-transport-file:jar:1.1.0:compile
+- org.eclipse.aether:aether-transport-http:jar:1.1.0:compile
|  +- org.apache.httpcomponents:httpclient:jar:4.3.5:compile
|  |  +- org.apache.httpcomponents:httpcore:jar:4.3.2:compile
|  |  \- commons-codec:commons-codec:jar:1.6:compile
|  \- org.slf4j:jcl-over-slf4j:jar:1.6.2:compile
+- org.apache.maven:maven-aether-provider:jar:3.3.3:compile
|  +- org.apache.maven:maven-model:jar:3.3.3:compile
|  +- org.apache.maven:maven-model-builder:jar:3.3.3:compile
|  |  +- org.codehaus.plexus:plexus-interpolation:jar:1.21:compile
|  |  +- org.apache.maven:maven-builder-support:jar:3.3.3:compile
|  |  \- com.google.guava:guava:jar:18.0:compile
|  +- org.apache.maven:maven-repository-metadata:jar:3.3.3:compile
|  +- org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
|  \- org.codehaus.plexus:plexus-utils:jar:3.0.20:compile
+- de.continentale.spu:rrep-pjava-index:jar:0.0.1-SNAPSHOT:compile
|  \- de.regnis.q.sequence:sequence-library:jar:1.0.2:compile
+- org.tmatesoft.svnkit:svnkit:jar:1.8.12:compile
|  +- com.jcraft:jsch.agentproxy.svnkit-trilead-ssh2:jar:0.0.7:compile
|  |  \- com.jcraft:jsch.agentproxy.core:jar:0.0.7:compile
|  +- com.trilead:trilead-ssh2:jar:1.0.0-build220:compile
|  +- net.java.dev.jna:jna-platform:jar:4.1.0:compile
|  +- net.java.dev.jna:jna:jar:4.1.0:compile
|  \- com.jcraft:jsch.agentproxy.connector-factory:jar:0.0.7:compile
|     +- com.jcraft:jsch.agentproxy.usocket-jna:jar:0.0.7:compile
|     |  \- net.java.dev.jna:platform:jar:3.4.0:compile
|     +- com.jcraft:jsch.agentproxy.usocket-nc:jar:0.0.7:compile
|     +- com.jcraft:jsch.agentproxy.sshagent:jar:0.0.7:compile
|     \- com.jcraft:jsch.agentproxy.pageant:jar:0.0.7:compile
+- org.tmatesoft.sqljet:sqljet:jar:1.1.9:compile
|  \- org.antlr:antlr-runtime:jar:3.4:compile
+- commons-io:commons-io:jar:2.4:compile
+- org.apache.commons:commons-lang3:jar:3.1:compile
\- log4j:log4j:jar:1.2.14:compile

我不清楚如何避免SLF4J错误。

编辑:

我正在使用Eclipse以太联系Maven存储库

private static RepositorySystem newRepositorySystem()
{
DefaultServiceLocator locator = MavenRepositorySystemUtils
    .newServiceLocator();
locator.addService(RepositoryConnectorFactory.class,
    BasicRepositoryConnectorFactory.class);
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
RepositorySystem service = locator.getService(RepositorySystem.class);
return service;
}

RepositorySystem service = locator.getService(RepositorySystem.class);产生错误,因为它可能是第一个联系SLF4J的位置。

1 个答案:

答案 0 :(得分:0)

问题出在Eclipse Workspace Resolution for Maven中。

显然,在不同项目的.classpath中引用的jar可以覆盖m2e依赖项解析中的POM值。

整理完第二个项目后,一切正常。