当前位置: 首页 > 知识库问答 >
问题:

SLF4J:类路径包含多个SLF4J绑定警告

易英奕
2023-03-14

我在其他问题中看到,通常此警告的解决方案是从导致此冲突的依赖项中排除slf4j,但我无法在我的项目中发现问题。

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Applications/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [file:/Applications/Eclipse.app/Contents/Eclipse/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]

我运行mvn dependency:tree命令,输出如下:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ subscriptionsmanager ---
[INFO] it.pietro:subscriptionsmanager:jar:0.0.1-SNAPSHOT
[INFO] +- junit:junit:jar:4.13.1:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.mockito:mockito-core:jar:3.5.13:test
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.10.15:test
[INFO] |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.15:test
[INFO] |  \- org.objenesis:objenesis:jar:3.1:test
[INFO] +- org.mongodb:mongo-java-driver:jar:3.12.7:compile
[INFO] +- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO] |  +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- de.bwaldvogel:mongo-java-server:jar:1.11.1:compile
[INFO] |  +- de.bwaldvogel:mongo-java-server-core:jar:1.11.1:compile
[INFO] |  |  +- io.netty:netty-transport:jar:4.1.31.Final:compile
[INFO] |  |  |  +- io.netty:netty-buffer:jar:4.1.31.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-common:jar:4.1.31.Final:compile
[INFO] |  |  |  \- io.netty:netty-resolver:jar:4.1.31.Final:compile
[INFO] |  |  \- io.netty:netty-codec:jar:4.1.31.Final:compile
[INFO] |  \- de.bwaldvogel:mongo-java-server-memory-backend:jar:1.11.1:compile
[INFO] +- org.assertj:assertj-core:jar:3.15.0:test
[INFO] +- org.testcontainers:mongodb:jar:1.15.1:compile
[INFO] |  \- org.testcontainers:testcontainers:jar:1.15.1:compile
[INFO] |     +- org.apache.commons:commons-compress:jar:1.20:compile
[INFO] |     +- org.rnorth.duct-tape:duct-tape:jar:1.0.8:compile
[INFO] |     +- org.rnorth.visible-assertions:visible-assertions:jar:2.1.2:compile
[INFO] |     |  \- net.java.dev.jna:jna:jar:5.2.0:compile
[INFO] |     +- com.github.docker-java:docker-java-api:jar:3.2.7:compile
[INFO] |     |  \- com.fasterxml.jackson.core:jackson-annotations:jar:2.10.3:compile
[INFO] |     \- com.github.docker-java:docker-java-transport-zerodep:jar:3.2.7:compile
[INFO] |        \- com.github.docker-java:docker-java-transport:jar:3.2.7:compile
[INFO] +- org.assertj:assertj-swing-junit:jar:3.17.1:test
[INFO] |  +- org.assertj:assertj-swing:jar:3.17.1:test
[INFO] |  |  \- org.easytesting:fest-util:jar:1.2.5:test
[INFO] |  \- org.easytesting:fest-reflect:jar:1.4.1:test
[INFO] \- info.picocli:picocli:jar:4.5.2:compile

共有2个答案

怀经赋
2023-03-14

可以通过在导致冲突的依赖项(pom.xml)中添加以下排除项来解决此问题。

 <exclusions>
    <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
    </exclusion>
 </exclusions> 
宰父夕
2023-03-14

SLF4J绑定警告来自Eclipse IDE本身,与您在Eclipse IDE中编写的应用程序无关。所以它只是可以忽略的噪音(参见例如这里和这里)。

我猜您已经为企业Java开发人员安装了EclipseIDE,可能还安装了一些附加插件。那是900多罐。SLF4J被Maven对Eclipse的支持(在SLF4J绑定警告中称为m2e)使用,并且至少还有一个其他插件以不兼容的方式使用,从而导致此警告。Eclipse基于OSGi,在OSGi中没有平坦的类路径,可以在运行时安装、启动、停止和卸载插件/捆绑包。SLF4J的构建似乎没有考虑OSGi,因此误导性的警告类路径包含多个SLF4J绑定,尽管OSGi中没有使用自己的类加载器的类路径。

 类似资料:
  • 我得到以下错误。似乎有多个日志记录框架绑定到SLF4J。不知道该怎么解决。非常感谢任何帮助。

  • 我在运行java代码时遇到以下运行时异常。有人能帮我解决绑定冲突吗。

  • 我在netbeans中有一个纯Java项目,我得到的警告是: 当然,我搜索了警告,但所有的答案都与用maven或pom.xml文件删除重复绑定有关。但是我没有pom.xml文件,也没有使用Maven。 那么如何排除绑定呢?

  • 在将apache.mahout添加到pom.xml之后,我在运行spring项目时开始出现这个警告,我想知道如何抑制这个警告。 这是我的pom.xml 我试图排除slf4j-log4j12,但仍然不能工作,每次都有警告 我找遍了所有的地方,但我无法移除警告。 有什么建议吗?

  • 我的应用程序服务器ibm WebSphere。我在应用程序服务器日志中得到以下错误。哪里可以设置websphere? [19.09.2012 14:56:54:940 EEST]0000000a SystemErr R SLF4J:类路径包含多个SLF4J绑定。 [19.09.2012 14:56:54:940 EEST]0000000a SystemErr R SLF4J:在[wsjar:fil