4

我有一个使用以下 Maven 依赖项的项目:

<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>

当我运行它时,它会给我警告抱怨:

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.

我的理解是有不止一个依赖包含slf4j。我应该可以从他们中排除 slf4j。但我不知道我的哪个依赖项实际上导致了这种情况。

有人可以帮忙吗?

问候

4

2 回答 2

14

尝试运行mvn dependency:tree -Dincludes=*slf4j*。它应该向您显示哪个工件定义了对 slf4j 的依赖关系。

附加参数可用于过滤特定的 slf4j 依赖项。有关特定依赖项的插件和过滤的更多信息,请参见此处

于 2012-05-04T15:09:50.383 回答
4

要检查您的依赖项来自何处,请尝试mvn dependency:tree

于 2012-05-04T15:02:26.217 回答