我得到如下错误。似乎有多个日志框架绑定到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.

当前回答

... org.codehaus.mojo cobertura-maven-plugin 2.7 测验 ch.qos.logback logback-classic 工具 com.sun ...

##我用这个来修复

... org.codehaus.mojo cobertura-maven-plugin 2.7 测验 ch.qos.logback logback-classic 工具 com.sun ...

其他回答

我通过Intellij项目中的Project Structure解决了这个问题。 我删除了名为:Maven: org.apache.logging.log4j:log4j-to-slf4j-impl:2.14.1的文件

这个文件没有显示在这张图片中。您可能会看到两个库被称为log4j-to-slf4j。删除一个就可以了。

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

如果这些日志是此修复的结果: https://stackoverflow.com/a/9919375/2894819

当你的某个库实际使用它时。而且您的应用程序不需要SL4J,只需将实现替换为runtimeOnly即可。

// contains dependency to sl4j-api
implementation("com.github.doyaaaaaken:kotlin-csv-jvm:1.2.0")

// add this to remove both warnings
runtimeOnly("org.slf4j:slf4j-nop:1.7.36")

在这种情况下,当你运行你的应用程序时,实际的依赖关系将被库包含一次,而不会被包含到你的application.jar本身的bundle中。

Gradle版;

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

我在一个非maven项目中得到了这个问题,两个依赖的jar每个都包含一个slf4j。我解决了 通过删除一个依赖的jar,编译项目(当然会失败),然后将删除的jar添加回来。