gradle - SLF4J : multiple SLF4J bindings with Gradle Plugin

标签 gradle plugins log4j2

我知道 SLF4J 的问题是一个常见问题:类路径包含多个 SLF4J 绑定(bind)。

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 build 并应用了 gradle-plugin 插件时出现此错误
例如类与
import org.gradle.api.*
class CommonTestPlugin implements Plugin<Project> {

并在 gradle
apply plugin: 'java-gradle-plugin'  

我正在使用该插件,因此我可以添加代码来创建插件。

上面的错误似乎指向 gradle-api 作为有问题的依赖项,但是当我启动依赖项洞察任务时
dependencyInsight -- 依赖 gradle-api

它返回:
No dependencies matching given input were found in configuration ':compileClasspath'

我的问题是:如何确定如何定义/排除插件正在使用的依赖项?我使用类似以下的东西,我只是不知道如何将它应用到插件 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 中粗暴地排除:

bootJar{
  exclude('gradle-api-*.jar', 'groovy-*.jar')
}

我正在使用 Spring Boot 插件。 bootJar扩展 jar任务。

但是,问题仍然存在:插件的所有用户是否都必须进行这种排除恶作剧才能使其正常工作?

关于gradle - SLF4J : multiple SLF4J bindings with Gradle Plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51644795/

相关文章:

android - Gradle生成的APK名称始终带有 “app”,而不是我的应用名称

android - Gradle 错误 - 在 APK AndroidManifest.xml 中复制了重复文件

javascript - 光滑 slider : Get rid of partial/edge images in centerMode

eclipse - Groovy Eclipse 插件组织导入

java - log4j2.xml 虚拟机选项 "No log4j2 configuration file found"

java - log4j2 - 错误记录器记录器没有与元素 AppenderRef 匹配的参数

gradle - 分解cucumber-jvm.jar时出现文件许可权错误

scala - 使用TestNG(和Gradle)进行覆盖

安卓工作室 2.0 : Gradle DSL method not found: 'classpath()' error(27, 0)

java - Log4j2 Silence 特定包