有事没事领个红包

maven依赖包冲突解决办法

今天在写一个demo时报了以下错误

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/chengxu/mavenRepository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/D:/chengxu/mavenRepository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.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 [org.slf4j.impl.Log4jLoggerFactory]
log4j:WARN No appenders could be found for logger (us.codecraft.webmagic.scheduler.QueueScheduler).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

 

一看就是 SLF4J 依赖冲突,查看一下有哪些包依赖了 SLF4J

使用命令:

mvn dependency:tree -Dverbose -Dincludes=org.slf4j

输出如下

复制代码
[INFO] --- maven-dependency-plugin:3.0.1:tree (default-cli) @ stock ---
[INFO] Verbose not supported since maven-dependency-plugin 3.0
[INFO] com.huitong:stock:pom:1.0-SNAPSHOT
[INFO] +- us.codecraft:webmagic-core:jar:0.7.3:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  \- org.slf4j:slf4j-log4j12:jar:1.7.25:compile
[INFO] \- org.springframework.boot:spring-boot-starter-aop:jar:2.0.0.RELEASE:compile
[INFO]    \- org.springframework.boot:spring-boot-starter:jar:2.0.0.RELEASE:compile
[INFO]       \- org.springframework.boot:spring-boot-starter-logging:jar:2.0.0.RELEASE:compile
[INFO]          \- org.slf4j:jul-to-slf4j:jar:1.7.25:compile
复制代码

可以看到webmagic-core 和 springboot-starter-aop 相冲突,所以在 pom 文件修改

复制代码
<dependency>
      <groupId>us.codecraft</groupId>
      <artifactId>webmagic-core</artifactId>
      <version>0.7.3</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
          <groupId>log4j</groupId>
          <artifactId>log4j</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
复制代码

再运行即可

 

posted @   crazyCodeLove  阅读(1175)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2017-04-06 jdbc链接基础
2017-04-06 MySQL数据约束和关联查询
2017-04-06 mysql基本操作语句
点击右上角即可分享
微信分享提示