欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

springboot关于ClasspathcontainsmultipleSLF4Jbindings.警告的maven解决

时间:2023-07-29

启动时报错信息

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 

org.apache.dubbo dubbo-dependencies-zookeeper 3.0.5 pom org.slf4j slf4j-log4j12

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

看日志有如下警告

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.ConsoleAppenderlog4j.appender.stdout.Target=System.outlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。