排查maven依赖冲突
项目启动告警
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/Intellij/install/apache-maven-3.6.1/maven-repo/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:/Intellij/install/apache-maven-3.6.1/maven-repo/org/apache/logging/log4j/log4j-slf4j-impl/2.12.1/log4j-slf4j-impl-2.12.1.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]
Slf4j的jar包冲突,虽然不影响项目启动运行,但是不知道会有什么潜在的异常。
log4j-slf4j-impl-2.12.1.jar 和 logback-classic-1.2.3.jar冲突,这两个包是在别的依赖带过来的。所以需要查看包结构,排除掉一个依赖
使用maven依赖分析工具
下载地址 https://plugins.jetbrains.com/plugin/7179-maven-helper/versions
下载后导入idea的plugins并重启idea
然后点击pom.xml文件 → 左下角 DependencyAnalyzer ,搜索 log,就可以根据 告警信息找到对应的依赖所依赖的两个冲突的jar包
最后在pom.xml文件中,排除掉对应的依赖即可(我这里是发现pom文件中引入了log4j2的依赖,注释掉即可)
<!-- log4j2的依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
参考文章:https://www.jiweichengzhu.com/article/241cf96c495f4725bb17f7c7b8a100eb