4.1 springboot中log4j冲突规避!


参考 https://blog.csdn.net/g631521612/article/details/82381435?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.control

 
SLF4J: Class path contains multiple SLF4J bindings.
 
SLF4J: Found binding in [jar:file:/D:/apache-maven-3.6.3/localRepository/ch/qos/logback/logback-classic/1.2.3/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
 
SLF4J: Found binding in [jar:file:/D:/apache-maven-3.6.3/localRepository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.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的冲突并未解决,导致启动失败,根据上面的报错信息,找到logback-classic-1.2.3.jar和slf4j-log4j12-1.7.25.jar的相应位置删除,并在pom.xml中加入如下排除代码:
< dependency >
< groupId > org.springframework.boot </ groupId >
< artifactId > spring-boot-starter-web </ artifactId >
<!-- 排除默认的 logback 日志,使用 log4j-->
< exclusions >
< exclusion >
< groupId > org.springframework.boot </ groupId >
< artifactId > spring-boot-starter-logging </ artifactId >
</ exclusion >
<!--<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>-->
< exclusion >
< groupId > ch.qos.logback </ groupId >
< artifactId > logback-classic </ artifactId >
</ exclusion >
</ exclusions >
</ dependency >
 
注释两者其中的一个就行
 
 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM