Today I met this error when build my project.

SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/apps/... fbb0e/logback-classic-1.2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/apps/... eca4e/slf4j-log4j12-1.7.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder]

I find that this is a dependency collision which sometimes happens when you add lots of dependencies to your project.

To solve this problem, we need to check the dependencies tree.

Double click this

Or use this command:

gradle dependencies --configuration runtime 

You will get this kind of output:

+--- org.codehaus.groovy:groovy-all:2.6.0-alpha-2
+--- net.bytebuddy:byte-buddy:1.6.11
+--- commons-io:commons-io:2.6
+--- org.apache.odftoolkit:simple-odf:0.8.2-incubating
|    +--- org.apache.odftoolkit:odfdom-java:0.8.11-incubating
|    |    +--- org.apache.odftoolkit:taglets:0.8.11-incubating
|    |    +--- xerces:xercesImpl:2.9.1 -> 2.11.0
|    |    |    \--- xml-apis:xml-apis:1.4.01
|    |    +--- xml-apis:xml-apis:1.3.04 -> 1.4.01
|    |    +--- org.apache.jena:jena-core:2.11.2
|    |    |    +--- org.slf4j:slf4j-api:1.7.6 -> 1.7.22
|    |    |    +--- org.apache.jena:jena-iri:1.0.2
|    |    |    |    +--- org.slf4j:slf4j-api:1.7.6 -> 1.7.22
|    |    |    |    \--- log4j:log4j:1.2.17
|    |    |    +--- xerces:xercesImpl:2.11.0 (*)
|    |    |    \--- log4j:log4j:1.2.17
|    |    +--- net.rootdev:java-rdfa:0.4.2
|    |    |    +--- org.apache.jena:jena-iri:0.9.1 -> 1.0.2 (*)
|    |    |    \--- org.slf4j:slf4j-api:1.5.6 -> 1.7.22
|    |    \--- commons-validator:commons-validator:1.5.0
|    |         +--- commons-beanutils:commons-beanutils:1.9.2
|    |         |    +--- commons-logging:commons-logging:1.1.1 -> 1.2
|    |         |    \--- commons-collections:commons-collections:3.2.1 -> 3.2.2
|    |         +--- commons-digester:commons-digester:1.8.1
|    |         +--- commons-logging:commons-logging:1.2
|    |         \--- commons-collections:commons-collections:3.2.2
|    +--- xerces:xercesImpl:2.9.1 -> 2.11.0 (*)
|    \--- xml-apis:xml-apis:1.3.04 -> 1.4.01
+--- org.apache.lucene:lucene-core:6.+ -> 6.6.2
+--- org.apache.lucene:lucene-analyzers-common:6.+ -> 6.6.2
|    \--- org.apache.lucene:lucene-core:6.6.2
+--- org.apache.lucene:lucene-queryparser:6.+ -> 6.6.2
|    +--- org.apache.lucene:lucene-core:6.6.2
|    +--- org.apache.lucene:lucene-queries:6.6.2
|    \--- org.apache.lucene:lucene-sandbox:6.6.2
+--- commons-io:commons-io:2.5 -> 2.6
\--- ch.qos.logback:logback-classic:1.2.1
     +--- ch.qos.logback:logback-core:1.2.1
     \--- org.slf4j:slf4j-api:1.7.22 

And you can search the collision package and exclude one of them in the build.gradle file.

configurations.all {
    exclude group: "org.slf4j", module: "slf4j-log4j12"
} 

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *