可以转到pom.xml,打开Dependency Hierarchy并找到slf4j条目。除了通过右键单击“exclude maven artifact”排除其余条目。
标签:除了 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