码迷,mamicode.com
首页 > 编程语言 > 详细

Maven中日志jar包冲突报错:Class path contains multiple SLF4J bindings

时间:2018-11-25 20:07:18      阅读:352      评论:0      收藏:0      [点我收藏+]

标签:除了   pom.xml   .com   排除   important   ber   dep   depend   normal   

错误表现:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/learn/Java/maven/repository_taotao/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/learn/Java/maven/repository_taotao/org/apache/activemq/activemq-all/5.11.2/activemq-all-5.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

控制台报错如下图所示:

 技术分享图片

错误原因:
发生jar包冲突了:
分别为:

SLF4J: Found binding in [jar:file:/D:/learn/Java/maven/repository_taotao/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/learn/Java/maven/repository_taotao/org/apache/activemq/activemq-all/5.11.2/activemq-all-5.11.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]

解决方案:

 

可以转到pom.xml,打开Dependency Hierarchy并找到slf4j条目。除了通过右键单击“exclude maven artifact”排除其余条目。

运行mvn dependency:tree并搜索哪些依赖项具有slf4j您不想要的实现,然后使用依赖项排除将其排除,例如:

        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
        </dependency>
        <!-- 配置对ActiveMQ客户端的依赖jar包 -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-all</artifactId>
        </dependency>
        <dependency>
            <groupId>com.taotao</groupId>
            <artifactId>taotao-common</artifactId>
            <version>0.0.1-SNAPSHOT</version>
            <exclusions>
                <exclusion>
                    <artifactId>slf4j-log4j12</artifactId>
                    <groupId>org.slf4j</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

Maven中日志jar包冲突报错:Class path contains multiple SLF4J bindings

标签:除了   pom.xml   .com   排除   important   ber   dep   depend   normal   

原文地址:https://www.cnblogs.com/chenmingjun/p/10016456.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!