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】

相关推荐
2501_903238651 小时前
自定义登录页面的Spring Security实践
java·后端·spring·个人开发
飞翔的佩奇2 小时前
Java项目: 基于SpringBoot+mybatis+maven+mysql实现的图书管理系统(含源码+数据库+答辩PPT+毕业论文)
java·数据库·spring boot·mysql·spring·毕业设计·图书管理
jerry6093 小时前
注解(Annotation)
java·数据库·sql
Future_yzx4 小时前
Java Web的发展史与SpringMVC入门学习(SpringMVC框架入门案例)
java·前端·学习
辞半夏丶北笙5 小时前
最近最少使用算法(LRU最近最少使用)缓存替换算法
java·算法·缓存
星如雨グッ!(๑•̀ㅂ•́)و✧5 小时前
Java NIO全面详解
java·python·nio
taopi20246 小时前
android java系统弹窗的基础模板
android·java·开发语言
松仔log7 小时前
Java多线程——对象的组合
java·开发语言·jvm
酷爱码7 小时前
springboot 动态配置定时任务
java·spring boot·后端
从未止步..8 小时前
Jenkins未在第一次登录后设置用户名,第二次登录不进去怎么办?
java·运维·jenkins