IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突

报错信息截图如下:

IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突_第1张图片

日志信息如下:

 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.SimpleLoggerFactory loaded from

file:/D:/Apache%20Software%20Foundation/LocalWarehouse/org/slf4j/slf4j-simple/1.7.30/slf4j-simple-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.SimpleLoggerFactory 

通过日志信息得知两个jar包里面的方法产生了冲突

 [jar:file:/D:/Apache%20Software%20Foundation/LocalWarehouse/org/slf4j/slf4j-simple/1.7.30/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
[jar:file:/D:/Apache%20Software%20Foundation/LocalWarehouse/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]

得知将  slf4j-simple 包排出即可

经过四步排出发生冲突的依赖后,我的项目pom文件发生了变化,最后项目运行成功!

IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突_第2张图片

 排出依赖的方法:

第一步,安装一个插件

IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突_第3张图片

 第二步,重启idea后(如果插件已安装可不重启),点击Dependency Analyzer

IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突_第4张图片

 第三步,搜索项目发生冲突的包名(注意 点击按钮 Refresh UI 刷新依赖勾选All Dependencies as ListIDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突_第5张图片

 第四步,将发生冲突的依赖排出

IDEA 报错 LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. 如何解决依赖冲突_第6张图片

最后,经过以上4步项目运行成功!没有bug的项目不是好项目(哭.jpg) 

你可能感兴趣的:(springboot,实战项目,logback,java,开发语言,intellij-idea)