码迷,mamicode.com
首页 > 编程语言 > 详细

SpringBoot LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

时间:2019-06-25 10:06:58      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:目的   http   static   file   load   lan   nat   boot   contains   

SpringBoot 在启动项目的时候一起错误:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/tongqinyuan/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/tongqinyuan/.m2/repository/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]
Exception in thread "main" java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/Users/tongqinyuan/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar). If you are using WebLogic you will need to add ‘org.slf4j‘ to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactory

其实这是slf4j 日志包冲出导致 ,怎么查看包冲突呢?

zookeeper包和junit包中都引入了日志包:

<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
安装maven help 插件,在pom.xml文件下点击dependency Analyzer分析查看冲突的包

 

 

找到冲突后通过exclude排除掉就好了;

 

SpringBoot LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

标签:目的   http   static   file   load   lan   nat   boot   contains   

原文地址:https://www.cnblogs.com/exmyth/p/11080547.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!