SpringCloud项目里slf4j依赖冲突问题解决

项目启动的时候会报SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Found binding in [jar:file:.../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:.../org/apache/logging/log4j/log4j-slf4j-impl/1.7.25/log4j-slf4j-impl-2.11.2.jar!/org/slf4j

/impl/StaticLoggerBinder.class]

网上搜了下,都是如下这种:

1、“SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/D:/maven-3.3.3/m2/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-3.3.3/m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org

/slf4j/impl/StaticLoggerBinder.class]”

2、“

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/G:/repo/repo-mvn-qingmu/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:/G:/repo/repo-mvn-qingmu/org/slf4j/slf4j-log4j12/1.7.30
/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]”

大致可以看到都是
slf4j-log4j12-xxx.jar这种多出来的依赖,而我这个是log4j-slf4j-impl-2.11.2.jar,还是不一样的,因为我要用logback,
所以要解决的肯定时log4j-slf4j-impl-2.11.2.jar依赖。

解决过程:
排查每个Module的依赖,idea里有工具可以看的,然后找到log4j-slf4j-impl-2.11.2.jar,看谁依赖了它,然后在其下加入:
<exclusions>
            <exclusion>
                <groupId>org.apache.log4j</groupId>
                <artifactId>log4j-slf4j-impl</artifactId>
            </exclusion>
        </exclusions>
posted @ 2020-08-07 09:54  美少女壮士2333  阅读(2769)  评论(0编辑  收藏  举报