【SpringBoot】SLF4J: Class path contains multiple SLF4J bindings.

问题描述

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绑定。


解决方案

修改pom.xml,排除j2cache-core和j2cache-spring-boot2-starter中的slf4j-simple依赖。

        <dependency>
            <groupId>net.oschina.j2cachegroupId>
            <artifactId>j2cache-coreartifactId>
            <version>2.8.5-releaseversion>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4jgroupId>
                    <artifactId>slf4j-simpleartifactId>
                exclusion>
            exclusions>
        dependency>

        <dependency>
            <groupId>net.oschina.j2cachegroupId>
            <artifactId>j2cache-spring-boot2-starterartifactId>
            <version>2.8.0-releaseversion>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4jgroupId>
                    <artifactId>slf4j-simpleartifactId>
                exclusion>
            exclusions>
        dependency>

你可能感兴趣的:(SpringBoot,spring,boot,后端,java)