簡體   English   中英

SLF4J:Class 路徑包含多個 SLF4J 綁定警告

[英]SLF4J: Class path contains multiple SLF4J bindings warning

我在其他問題中看到,通常解決此警告的方法是將 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命令,這是 output:

[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

The SLF4J bindings warning comes from the Eclipse IDE itself and is not related to your application you write in the Eclipse IDE. 所以它只是可以忽略的噪音(參見例如herehere )。

我猜你有Eclipse IDE 用於企業 Java 開發人員可能安裝了一些額外的插件。 那是超過 900 個 JARs。 Maven 使用 SLF4J 支持 Eclipse (在 SLF4J 綁定中警告為m2e )以及至少一個其他插件以不兼容的方式導致此警告。 Eclipse 基於 OSGi,沒有平面類路徑,並且可以在運行時安裝、啟動、停止和卸載插件/捆綁包。 SLF4J 似乎沒有考慮到 OSGi 構建,因此誤導性警告Class path contains multiple SLF4J bindings ,盡管 OSGi 中沒有使用自己的 class 加載程序的類路徑。

您可以通過在導致沖突的依賴項(pom.xml)中添加以下排除項來解決此問題。

<exclusions>
<exclusion>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
</exclusion>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM