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】

相关推荐
别动我齐刘海3 小时前
C++ 工程化学习
java·linux·前端·c++·学习·机器学习·机器人
code2cat4 小时前
Java进阶篇之AtomicLongFieldUpdater:把累计额度留在对象字段中
java·cas·并发编程
WeiXin_DZbishe4 小时前
基于springboot城市公交实时运营与调度系统-计算机毕设 附源码【课程设计】66173
java·vue.js·spring boot·后端·python·php·课程设计
泡茶喝茶写代码4 小时前
A股量化数据工程:从 REST 接口到策略信号(第 18 篇):放量缩量异动扫描
java·python·股票数据api·股票数据api接口·股票api数据接口·股票量化数据api·股票量化数据接口
wewowilling5 小时前
认识微服务
java·运维·微服务·springcloud
代码什么用5 小时前
Java Web 7-10
java·servlet
蜗牛互联网7 小时前
GPT-6 与 Intelligent UI:从回答到可审计操作的产品迁移
java·人工智能·后端
SL_staff7 小时前
运维救火实录:钉钉考勤API变更引发工资计算异常,我们用JVS-Logic可视化逻辑引擎实现分钟级热修复
java·mysql·全栈
SunnyDays10117 小时前
Java 查找并高亮 Word 文字:精确查找及正则表达式模糊查找
java·查找文字·word 文档·高亮文字·正则匹配查找·模糊查找