Error(13) 解决LoggerFactory is not a Logback LoggerContext but Logback is on the classpath
错误日志
Caused by: 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:/E:/IT_zhengqing/soft/soft-dev/Maven/repository-zhengqing/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.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
at org.springframework.util.Assert.instanceCheckFailed(Assert.java:699)
at org.springframework.util.Assert.isInstanceOf(Assert.java:599)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:284)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:104)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:232)
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)
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:74)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at com.zhengqing.system.SystemApplication.main(SystemApplication.java:15)
... 5 more
Process finished with exit code 1
问题分析
这里主要分析错误日志信息中的以下3点~
LoggerFactory is not a Logback LoggerContext but Logback is on the classpath.
得知日志jar包冲突Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/E:/IT_zhengqing/soft/soft-dev/Maven/repository-zhengqing/org/slf4j/slf4j-log4j12/1.7.30/slf4j-log4j12-1.7.30.jar).
提示排除Logback或与其冲突包的实现slf4j-log4jIf you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactory
提示如果需要使用WebLogic则添加org.slf4j相关依赖
解决
这里小编采取排除冲突包slf4j-log4j
来解决这一问题
pom.xml
-> Dependency Analyzer
-> 搜索slf4j-log4j
-> 右击选择Exclude
将其冲突依赖排除
温馨小提示:这里小编是通过maven插件
Maven Helper
来实现排除冲突的~Maven Helper
:主要用于分析和排除冲突依赖
最后项目启动成功!
今日分享语句:
- 一个人,只有学会了独立思考,学会了独自解决问题,才能扛起生活的责任和担当。
- 有的人,忍受不了孤独,害怕别人的眼光;有的人,朝着目标坚定前行,不在乎旁人的议论。往往,后者都拥有了更好的生活。回头再看,曾经在背后指指点点的人不知何时已经消失在了人海中。
- 生活,有时候是会觉得有点难;有些路,我们终究要学会一个人去走。挺过去,再回头看曾经经历的这些艰辛,其实也不过如此。这些经历,让我们变得坚强且勇敢,能更有自信地去面对未来的生活。
还没有评论,来说两句吧...