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