SpringBoot启动 控制台报错有关 @Slf4j 日志jar包冲突
1,bug
- ,SLF4J: Class path contains multiple SLF4J bindings
- .SLF4J: Found binding in [jar:file:
/D:/Program%20Files/apache-maven-3.5.2/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:
/D:/Program%20Files/apache-maven-3.5.2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.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]
原因在于:在这两个包下面,两个jar包冲突所导致的
2,解决方法:
1,点击打开pom.xml文件
2,右键,点击打开配置,选择Maven,点击选择-> Show Dependencies…进入下面的界面
3,从日志打印可以看出是 slf4j-log4j12 jar冲突,因此需要从项目中把其移除
注意:需要有依赖这个jar包的所有地方全部移除
使用ctrl + F 找到这个jar包所在的位置,右击这个jar包 然后选择 excluded 排除即可
1) ctrl + F在图中找到 slf4j-log4j12 jar,找到位置,如下图
2) 右键,选择 excluded 排除即可
4,再次运行idea,冲突已解决