SLF4J: Class path contains multiple SLF4J bindings. 问题原因及解决方法。
问题springboot项目,使用了slf4j,当引入zookeeper之后,就会报错:SLF4J: Class path contains multiple SLF4J bindings.SLF4J: Found binding in [jar:file:/Users/silence.hu/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/...
·
问题
springboot项目,使用了slf4j,当引入zookeeper之后,就会报错:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/silence.hu/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/silence.hu/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.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 [org.slf4j.impl.Log4jLoggerFactory]
由问题可以看出,是因为有多种SLFJ实现的绑定:logback-classic
和 slf4j-log4j12
.
因为我是引入zookeeper后才报的错,因此可以肯定是引入zookeeper后才起的jar包冲突,因此将zookeeper中的slf4j-log4j12
排除掉就好。
<!--zookeeper-->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
更多推荐
已为社区贡献1条内容
所有评论(0)