IDea寻找冲突的依赖包

场景:boot项目运行时,提示log4j2依赖包冲突。

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in jar:file:/D:/maven/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:/maven/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

解决方案:

1、比较费眼睛的方法:

pom.xml修改引用包排除slf4j-log4j12包.

采用mvn分析树查找引用关系的命令:

复制代码
#排错引用包继承关系
mvn dependency:tree

在输出的树型关系中找关于"slf4j-log4j12"的字样的引用包

INFO +- com.gitee.hsg77:pg-common:jar:1.1:compile

INFO | +- junit:junit:jar:4.12:compile

INFO | | \- org.hamcrest:hamcrest-core:jar:1.3:compile

INFO | +- org.apache.commons:commons-lang3:jar:3.8.1:compile

INFO | +- com.alibaba:fastjson:jar:1.2.60:compile

INFO | +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.7:compile

INFO | | \- com.fasterxml.jackson.core:jackson-core:jar:2.9.7:compile

INFO | +- com.github.pagehelper:pagehelper-spring-boot-starter:jar:1.2.5:compile

INFO | | +- org.mybatis.spring.boot:mybatis-spring-boot-starter:jar:1.3.2:compile

INFO | | | +- org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:jar:1.3.2:compile

INFO | | | +- org.mybatis:mybatis:jar:3.4.6:compile

INFO | | | \- org.mybatis:mybatis-spring:jar:1.3.2:compile

INFO | | +- com.github.pagehelper:pagehelper-spring-boot-autoconfigure:jar:1.2.5:compile

INFO | | \- com.github.pagehelper:pagehelper:jar:5.1.4:compile

INFO | +- com.github.jsqlparser:jsqlparser:jar:1.0:compile

INFO | +- org.projectlombok:lombok:jar:1.18.4:compile

INFO | +- org.springframework.boot:spring-boot-dependencies:pom:2.1.1.RELEASE:import

INFO | +- org.springframework:spring-context-support:jar:5.1.3.RELEASE:compile

INFO | +- mysql:mysql-connector-java:jar:8.0.13:compile

INFO | +- org.xerial:sqlite-jdbc:jar:3.25.2:compile

INFO | +- com.oracle:ojdbc6:jar:6.0:compile

INFO | +- com.microsoft.sqlserver:sqljdbc4:jar:4.2:compile

INFO | +- com.dameng:Dm8JdbcDriver18:jar:8.1.1.49:compile

INFO | +- com.h2database:h2:jar:1.4.197:compile

INFO | +- com.aliyun.hbase:alihbase-client:jar:1.1.12:compile

INFO | | +- com.aliyun.hbase:alihbase-annotations:jar:1.1.12:compile

INFO | | +- com.aliyun.hbase:alihbase-common:jar:1.1.12:compile

INFO | | | \- org.mortbay.jetty:jetty-util:jar:6.1.26:compile

INFO | | +- com.aliyun.hbase:alihbase-protocol:jar:1.1.12:compile

INFO | | +- commons-logging:commons-logging:jar:1.2:compile

INFO | | +- com.google.protobuf:protobuf-java:jar:2.5.0:compile

INFO | | +- io.netty:netty-all:jar:4.1.31.Final:compile

INFO | | +- org.apache.zookeeper:zookeeper:jar:3.4.6:compile

INFO | | | \- org.slf4j:slf4j-log4j12:jar:1.7.25:compile

最后一行为org.slf4j:slf4j-log4j12:jar:1.7.25:compile

引用来至包com.gitee.hsg77:pg-common:jar:1.1

所以解决办法如下所示:

pom.xml修改引用包排除slf4j-log4j12包

2、下载maven helper 插件

然后进到该pom文件,点击这里

输入搜索冲突的包

找到排除的jar,点击右键【exclude】

相关推荐
LuTshoes24 分钟前
spring ai 实战-MCP
java·人工智能·spring
CodeStats30 分钟前
【Java类加载器】Java 类加载器完整体系深度拆解(下):自定义加载器实战与 SPI 破坏双亲委派(MySQL 驱动揭秘)
java·开发语言·jvm·classloader·双亲委派
dishugj33 分钟前
操作系统四大特征|软考架构师考点梳理
java·linux·服务器
砚底藏山河42 分钟前
并发与限频工程:把20只的2秒压到0.5秒不封号(魔码量化实战 #03)
java·开发语言·数据库·python·金融
ly768943 分钟前
Spring WebFlux背压机制在生产环境的调优与陷阱
java·spring·microsoft·webflux·project reactor·背压·响应式流
云雀衔光1 小时前
MCP 协议全景:为什么它是 AI 连接工具的「USB-C」
java·开发语言·数据库·人工智能·ai编程
ly76891 小时前
Spring 异步编程的隐藏风险:@Async 线程池耗尽与异常处理详解
java·后端·spring·异常处理·线程池·任务拒绝
用户8181870627461 小时前
第23章 热点Key问题排查与解决:大促场景经典坑
java·后端
IT枫斗者枫哥1 小时前
Java 接口超时后,重试为什么会多建一条任务?
java
用户3126874877201 小时前
CAS 到底是怎么保证原子性的?从 Unsafe 到 VarHandle 的演进
java