今天在启动之前的Spring Boot项目的时候出现了这样的异常:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/H:/maven/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:/H:/maven/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]
Disconnected from the target VM, address: '127.0.0.1:6264', transport: 'socket'
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:/H:/maven/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.Log4jLoggerFactoryat org.springframework.util.Assert.instanceCheckFailed(Assert.java:637)at org.springframework.util.Assert.isInstanceOf(Assert.java:537)at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:274)at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:99)at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:191)at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:170)at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:68)at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)

显然是jar包冲突了,联想到前几天添加了ZooKeeper的相关依赖,将相关依赖排除即可。

解决方式一:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><exclusions><exclusion><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId></exclusion></exclusions>
</dependency>

或者

如果你项目的日志是基于Spring Boot的日志来的,建议不要使用这个方法。

解决方式二:

排除ZooKeeper中的依赖:

解决方式三:

依赖上移,我的ZooKeeper依赖是在service模块中,将其移至父工程中即可。

LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback相关推荐

  1. 分布式系统:SpringBoot中Dubbo以及Zookeeper依赖包冲突 LoggerFactory is not a Logback LoggerContext but Logback

    目录 QUESTION:SpringBoot中Dubbo以及Zookeeper依赖包冲突? ANSWER: 导入curator-recipes依赖: 排除依赖: QUESTION:SpringBoot ...

  2. springboot启动报错LoggerFactory is not a Logback LoggerContext but Logback...

    由于springboot默认日志组件为logback,当时项目使用的为log4j,在打war包到tomcat启动时报如上错误. 原因:log4j日志组件和自带logback日志组件冲突. 解决方法: ...

  3. slf4j的jar包冲突:LoggerFactory is not a Logback LoggerContext but Logback is on the classpath

    今天运行项目一直报上面那个错误,自己项目中有dozer的jar包 <dependency><groupId>net.sf.dozer</groupId><ar ...

  4. 【Spring 】启动报错 LoggerFactory is not a Logback LoggerContext but Logback...

    2.背景 写了一个程序,但是突然报错 这个是因为日志冲突,排除一个就好了. <dependency><groupld>orgapachehadoop

  5. 解决LoggerFactory is not a Logback LoggerEither remove Logback or the competing implementation (class

    一个项目引入了amqp以后报错,疑似包冲突,最后利用dependency analyzer终于解决了. 问题: 原依赖: <dependency><groupId>org.sp ...

  6. java中读取logback日志文件_java 控制台 System.out日志输出到logback文件里

    使用spring boot2.0.7开发项目,由于调用了其他组c++的本地方法,他们的日志是直接在控制台打印日志的,而我们这边统一用logback记录日志,然后logback配置后控制台的日志没有记录 ...

  7. Springboot工程logback和log4j冲突问题的解决。

    背景 刚入职,最近搭建一个工程.搭建过程需要引入公司已经封装好的一些jar包.引入jar后启动就会报错.报错信息如下 Exception in thread "restartedMain&q ...

  8. springboot 日志问题记录

    问题:新建工程busr,采用pandora boot,引入了需要的包,简单写了点代码发布, spring-boot启动报错: Caused by: java.lang.IllegalArgumentE ...

  9. SpringGateway与Zookeeper的Maven冲突

    原Maven依赖: <!--添加zookeeper3.4.14版本--> <dependency><groupId>org.apache.zookeeper< ...

  10. 工作中的一些错误解决记录

    1) 2018-10-19 CDH OOZIE UI页面打不开:    解决:     把下载好的ext-2.2.zip拷贝到Oozie主机的/var/lib/oozie目录下    运行命令unzi ...

最新文章

  1. 当前国内有哪些公司是做OKR管理软件做的比较好的?
  2. javax.validation.ParameterNameProvider
  3. 使用Backtrace函数打印调用栈 - Debug居家必备
  4. Java集合(一):Java集合概述
  5. 有趣的天平秤假币问题
  6. html文字竖直书写,css 文字竖直居中的写法和图片垂直居中代码(图文)
  7. oracle找出大于1g的表,表占用太大空间问题!
  8. Powershell基本命令总结(更新中)
  9. 【洛谷习题】又是毕业季II
  10. iperf3使用方法 linux,iperf3命令使用
  11. 阿里云SLS日志服务
  12. 大小和尚共有100人php,古今诗趣(一)· 数字诗
  13. Vijos 1004 伊甸园日历游戏 博弈
  14. xmarks 又可以使用了. 太棒了
  15. 微信加菲猫连接服务器失败,加菲猫微信表情包
  16. 【BZOJ3837】[Pa2013]Filary 随机化神题
  17. 【C语言】交换函数(swap)
  18. 18年春季第一题 PAT甲级 1144 The Missing Number (20分) 上限感很重要
  19. 大学四年,我是如何学习编程的?
  20. 投:分众传媒相关文章

热门文章

  1. windows7 快捷方式 图标显示异常的解决
  2. Java多态实例主人和狗狗企鹅玩游戏
  3. xp系统计算机蓝屏,xp系统电脑一直蓝屏重启循环的原因和解决方法
  4. 计算机主板上的纽扣电池型号是,主板上的纽扣电池是什么
  5. web工程无法访问本地图片解决方案
  6. 如何摆脱CRUD等打杂状态,从事更高价值工作
  7. 丁磊一份隔着万水千山的爱情
  8. mysql瀑布流布局插件_瀑布流JS插件
  9. 2022-2028年中国中频加热设备行业市场发展调研及未来前景规划报告
  10. vs2017发布网站到IIS