SringBoot的Application启动报错:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/G:/.m2/repository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/G:/.m2/repository/org/slf4j/slf4j-log4j12/1.7.21/slf4j-log4j12-1.7.21.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 [ch.qos.logback.classic.util.ContextSelectorStaticBinder]
原因:logback-classic包和slf4j包冲突。
解决方法:
找到哪个依赖引入了logback-classic,然后用依赖排除标签排除掉。
具体解决:
其中slf4j-log4j12包是我在pom中引入的,说明logback-classic包是其他依赖中引用的。在pom文件的Depency Hierarchy页签中,找到:
是spring-boot-starter-jdbc包引入的。
(也可以用mvn dependency:tree
命令查看依赖关系)
在pom中排除掉:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId> <!--排除-->
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions> </dependency>