当前位置:   article > 正文

spring-boot-starter-log4j2和spring-boot-starter-logging同时存在会产生冲突_spring-boot-starter-logging 和 log4j2

spring-boot-starter-logging 和 log4j2

错误日志:

  1. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  2. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
  3. Exception in thread "main" java.lang.StackOverflowError
  4. at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:112)
  5. at org.apache.logging.log4j.util.StackLocator.getCallerClass(StackLocator.java:125)
  6. at org.apache.logging.log4j.util.StackLocatorUtil.getCallerClass(StackLocatorUtil.java:55)
  7. at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
  8. at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
  9. at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
  10. at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)

产生此错误的原因:logback-classic包和slf4j包冲突。 

解决方法:

找到哪个依赖引入了logback-classic,然后用依赖排除标签排除掉。

 

找到了,然后:

<!--springboot-websocket服务-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-websocket</artifactId>
    <!--排除-->
    <exclusions>
        <exclusion>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </exclusion>
    </exclusions>
</dependency>
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/代码探险家/article/detail/813249
推荐阅读
相关标签
  

闽ICP备14008679号