问题描述
SpringBoot整合j2cache,启动时报错。
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/xxx/.m2/repository/ch/qos/logback/logback-classic/1.2.5/logback-classic-1.2.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/xxx/.m2/repository/org/slf4j/slf4j-simple/1.7.32/slf4j-simple-1.7.32.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]
原因分析
类路径包含多个SLF4J绑定,这可能会导致SLF4J绑定冲突,从而引发启动时的错误。
解决方案
修改pom.xml,排除j2cache-core和j2cache-spring-boot2-starter中的slf4j-simple依赖,以解决SLF4J绑定冲突问题。文章来源:https://www.toymoban.com/news/detail-681757.html
<dependency>
<groupId>net.oschina.j2cache</groupId>
<artifactId>j2cache-core</artifactId>
<version>2.8.5-release</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.oschina.j2cache</groupId>
<artifactId>j2cache-spring-boot2-starter</artifactId>
<version>2.8.0-release</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
通过以上排除操作,我们成功解决了SLF4J绑定冲突的问题,确保应用能够顺利启动并正确运行。文章来源地址https://www.toymoban.com/news/detail-681757.html
到了这里,关于【SpringBoot】SLF4J: Class path contains multiple SLF4J bindings.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!