Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SLF4J version mismatch and duplicated binding

Tags:

java

maven

I have a project which uses the following maven dependencies:

<dependency>
                <groupId>com.dropbox</groupId>
                <artifactId>client2</artifactId>
                <version>1.3</version>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.8.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>4.0.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.0.3</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>4.0.3</version>
            </dependency>
            <dependency>
                <groupId>commons-logging</groupId>
                <artifactId>commons-logging</artifactId>
                <version>1.1.1</version>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.3</version>
            </dependency>
            <dependency>
                <groupId>org.json</groupId>
                <artifactId>simple</artifactId>
                <version>1.1</version>
            </dependency>
            <dependency>
                <groupId>com.google.inject</groupId>
                <artifactId>guice</artifactId>
                <version>3.0</version>
            </dependency>
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-all</artifactId>
                <version>1.9.0</version>
            </dependency>
            <dependency>
                <groupId>com.believer</groupId>
                <artifactId>box4j</artifactId>
                <version>1.2</version>
            </dependency>
            <dependency>
                <groupId>com.sun.jersey</groupId>
                <artifactId>jersey-client</artifactId>
                <version>1.12</version>
            </dependency>
            <dependency>
                <groupId>com.google.code.gson</groupId>
                <artifactId>gson</artifactId>
                <version>2.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.maven.surefire</groupId>
                <artifactId>surefire</artifactId>
                <version>2.12</version>
            </dependency>
        </dependencies>

When I run it, it gives me warning complaining:

SLF4J: The requested version 1.5.10 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/kzhang/.m2/repository/org/slf4j/slf4j-jdk14/1.5.10/slf4j-jdk14-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/kzhang/.m2/repository/org/slf4j/slf4j-simple/1.5.10/slf4j-simple-1.5.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/kzhang/.m2/repository/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

My understanding is that there are more than one dependencies contains slf4j. I should possible exclude slf4j from them. But I don't know which one of my dependencies actually causes this.

Can someone help with this?

Regards

like image 867
Kevin Avatar asked Dec 02 '22 22:12

Kevin


2 Answers

Try to run mvn dependency:tree -Dincludes=*slf4j*. It should show you which artifact defines the dependency to slf4j.

The additional parameter can be used to filter for the specific slf4j dependencies. For more about the plugin and filtering for specific dependencies see here.

like image 76
Behe Avatar answered Dec 19 '22 23:12

Behe


To check from where your dependencies come, try mvn dependency:tree .

like image 37
Rostislav Matl Avatar answered Dec 19 '22 23:12

Rostislav Matl