SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/yys1405/.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:/C:/Users/yys1405/.m2/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]

springboot项目启动时的告警,虽不影响正常运行,终究觉得不舒服,下面解决。

springboot 默认日志是,较新的logback 日志。但是在以前流行的日志却是log4j ,很多的第三方工具都含有log4j 的引入。在项目开发中,难免会引入各种各样的工具包。

解决:pom.xml中依赖slf4j-log4j12的工具包中去除引用,如下:

       <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>

举例:

<dependency>
     <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <!--排除这个slf4j-log4j12-->
        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
        </exclusions>
</dependency>

查看pom.xml的jar包依赖结构,参考:springboot 关于 Class path contains multiple SLF4J bindings.警告的解决

SLF4J: Class path contains multiple SLF4J bindings.

SLF4J: Class path contains multiple SLF4J bindings.