如下问题,slf4j发生多个地方引入,由于我是新增一个依赖时发生该问题,所以相对容易找到问题所在,直接在依赖添加了排除,clean下,重新运行即可。所以解决该问题需要你事先知道引入的依赖包是否包含了重复包,出现重复包时,需要手动加入排除依赖功能。
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/Administrator/.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:/C:/Users/Administrator/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.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]
<!--排除-->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
具体位置如下:
<dependency>
<groupId>xxx</groupId>
<artifactId>xxx</artifactId>
<version>xxxxx</version>
<!--排除-->
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
网上有一种解决tomcat日志包冲突,采用添加<scope>provided</scope>,因为provided表明该包只在编译和测试的时候使用。这种方式会导致新引入的包在运行时报错。
参考:https://stackoverflow.com/questions/22896243/maven-slf4j-class-path-contains-multiple-slf4j-bindings |