我得到如下错误。似乎有多个日志框架绑定到slf4j。不知道如何解决这个问题。任何帮助都非常感激。

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/admin/.m2/repository/org/slf4j/slf4j-log4j12/1.6.4/slf4j-log4j12-1.6.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/admin/.m2/repository/org/slf4j/slf4j-log4j12/1.6.1/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.

当前回答

Gradle版;

configurations.all {
    exclude module: 'slf4j-log4j12'
}

其他回答

我只是忽略/删除了那个jar文件。

我也有同样的问题。在我的pom.xml中,两者都有

 <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.28</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.2.1.RELEASE</version>
    </dependency>

当我删除spring-boot-starter-web依赖时,问题就解决了。

<!--<dependency>-->
     <!--<groupId>org.springframework.boot</groupId>-->
     <!--<artifactId>spring-boot-starter-log4j2</artifactId>-->
<!--</dependency>-->

我通过删除这个来解决:spring-boot-starter-log4j2

<scope>提供</scope>和< exclsions >的组合不适合我。

我不得不使用这个:

<dependency>
    <groupId>ch.qos.logback</groupId>
    <artifactId>logback-classic</artifactId>
    <scope>system</scope>
    <systemPath>${project.basedir}/empty.jar</systemPath>
</dependency>

其中empty.jar是一个没有任何内容的jar文件。

对我来说,答案是强制重新构建Maven。在Eclipse中:

右键单击项目-> Maven ->禁用Maven性质 右键单击项目-> Spring Tools > Update Maven Dependencies 右键单击项目->配置>转换Maven项目