其他分享
首页 > 其他分享> > springboot 关于 Class path contains multiple SLF4J bindings.警告的maven解决

springboot 关于 Class path contains multiple SLF4J bindings.警告的maven解决

作者:互联网

启动时报错信息

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/cb/.m2/repository/ch/qos/logback/logback-classic/1.2.10/logback-classic-1.2.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/cb/.m2/repository/org/slf4j/slf4j-log4j12/1.7.33/slf4j-log4j12-1.7.33.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]

问题分析

logback-classic-1.2.10.jar和slf4j-log4j12-1.7.33.jar同时引用了

查看疯关系图

 解决办法

修改pom.xmlgmf 

        <dependency>
            <groupId>org.apache.dubbo</groupId>
            <artifactId>dubbo-dependencies-zookeeper</artifactId>
            <version>3.0.5</version>
            <type>pom</type>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

再次启动没有上面的错误了

看日志有如下警告

log4j:WARN No appenders could be found for logger (org.apache.dubbo.config.spring.beans.factory.annotation.ServiceAnnotationPostProcessor).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. 

解决办法

增加log4j.properties文件

###set log levels###
log4j.rootLogger=info, stdout
###output to the console###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n

标签:multiple,springboot,stdout,contains,jar,SLF4J,slf4j,org,log4j
来源: https://blog.csdn.net/qq_14891839/article/details/122765498