![使用IDEA解决包依赖冲突的问题 Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory],第1张 使用IDEA解决包依赖冲突的问题 Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory],第1张](/aiimages/%E4%BD%BF%E7%94%A8IDEA%E8%A7%A3%E5%86%B3%E5%8C%85%E4%BE%9D%E8%B5%96%E5%86%B2%E7%AA%81%E7%9A%84%E9%97%AE%E9%A2%98+Actual+binding+is+of+type+%5Borg.apache.logging.slf4j.Log4jLoggerFactory%5D.png)
今天启动项目的时候出现jar包依赖冲突的问题,spring-boot项目默认使用logback日志库,然而又引入了log4j2导致出现下面的错误
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/86186/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.10.0/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/86186/.m2/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.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.StackOverflowError
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:112)
at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:125)
at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)
我使用的是gradle构建
所以在build.gradle里的dependencies里 将
implementation 'org.springframework.boot:spring-boot-starter-web'
改为
implementation('org.springframework.boot:spring-boot-starter-web'){
exclude group: "org.springframework.boot", module: "spring-boot-starter-logging"
}
排除掉spring-boot-starter-web里的spring-boot-starter-logging的依赖即可解决
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)