问题描述
对于SLF4J来说,我知道这是一个常见的问题:类路径包含多个SLF4J绑定.
I know its a common issue to have the issue with SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/<name>/.gradle/caches/4.9/generated-gradle-jars/gradle-api-4.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/<name>/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.2/afd596adf5086b4f4746254b25a3a4b513f1d6e4/log4j-slf4j-impl-2.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
运行gradle构建并应用gradle-plugin插件时出现此错误例如
I'm getting this error when I run a gradle build and I have applied the gradle-plugin plugine.g. class with
import org.gradle.api.*
class CommonTestPlugin implements Plugin<Project> {
并在gradle中
apply plugin: 'java-gradle-plugin'
我正在使用该插件,因此我可以添加代码来创建插件.
I'm using that plugin so I can add code to create a plugin.
上面的错误似乎指向gradle-api作为有问题的依赖关系,但是当我用dependencyInsight --dependency gradle-api
The error above seems to point to gradle-api as the offending dependency but I when I fired up the dependency-insight task withdependencyInsight --dependency gradle-api
它返回:
No dependencies matching given input were found in configuration ':compileClasspath'
我的问题是:我如何确定如何定义/排除插件正在使用的依赖关系?我正在使用类似以下的内容,我只是想不出如何将其应用于plugin-api
My question is: how can I determine how to define/exclude dependency that the plugin is using? Im using things like the following, I just can't figure out how to apply that to the plugin-api
compile (group: 'com.aestasit.infrastructure.sshoogr', name: 'sshoogr', version: '0.9.26'){
// exclude this to stop warnings about multiple SLF4J bindings.
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
推荐答案
我遇到了同样的问题.到目前为止,我发现的解决方法是将正在构建的目标JAR残酷地排除在外:
I've hit the same problem. The workaround I've found so far is a brutal exclusion from the target JAR being built:
bootJar{
exclude('gradle-api-*.jar', 'groovy-*.jar')
}
我正在使用Spring boot插件. bootJar
扩展了jar
任务.
I'm using Spring boot plugin. bootJar
extends jar
task.
问题仍然存在:为了使插件正常工作,插件的所有用户是否都必须进行这种排他性的研究?
The question remains, though: do all the users of a plugin must do this kind of exclusion hocus-pocus in order to get it to work?
这篇关于SLF4J:带有Gradle插件的多个SLF4J绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!