Gradle Internal slf4j与我自己的slf4j依赖项冲突

时间:2015-12-29 16:03:06

标签: java gradle slf4j

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/dev/gradle-2.9/lib/gradle-core-2.9.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Users/leo.j.lin/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-simple/1.5.11/14e29085f65a2e4e0f16e708f4135be122be562e/slf4j-simple-1.5.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Failed to instantiate SLF4J LoggerFactory

我已将这些作为我的依赖项包含在内。当我运行构建时,会发生上述错误。当我没有slf4j-simple依赖时,构建将失败,错误为"无法实例化SLF4J LoggerFactory"

    compile "org.slf4j:slf4j-api:1.5.11"
    compile "org.slf4j:slf4j-simple:1.5.11"

如何解决此问题?

我尝试了Class path contains multiple SLF4J bindings with Gradle,但它对我不起作用。

编辑:

这是根项目build.gradle

buildscript{

}

allprojects{

repositories {

    mavenCentral()
    mavenLocal()
    maven {
        url "https://repo.adobe.com/nexus/content/groups/public/"
    }
}

apply plugin: 'java'

dependencies{
    compile "org.osgi:org.osgi.core:4.2.0"
    compile "org.osgi:org.osgi.compendium:4.2.0"
    compile "org.apache.felix:org.apache.felix.scr.annotations:1.9.6"
    compile "biz.aQute:bndlib:1.50.0"
    compile "javax.servlet:servlet-api:2.5"
    compile "javax.jcr:jcr:2.0"
    compile "org.apache.sling:org.apache.sling.api:2.4.0"
    compile "org.apache.sling:org.apache.sling.jcr.api:2.1.0"
    compile "junit:junit:4.8.2"
    compile "com.day.cq:cq-tagging:5.6.4"
    compile "commons-logging:commons-logging:1.1.1"
    compile "org.apache.commons:commons-lang3:3.0.1"
    compile "com.day.commons.osgi.wrapper:com.day.commons.osgi.wrapper.commons-httpclient:3.1.0.018"
    compile "org.apache.sling:org.apache.sling.jcr.resource:2.2.9-R1523266"
    compile "org.apache.felix:org.apache.felix.scr:1.6.0"
    compile "com.adobe.aem:aem-api:6.0.0.1"
    compile "org.apache.sling:org.apache.sling.models.api:1.0.0"
    compile "javax.servlet.jsp:jsp-api:2.1"
    compile "com.day.cq.wcm:cq-wcm-taglib:5.7.4"
    compile "org.mockito:mockito-all:1.9.5"
    compile "junit-addons:junit-addons:1.4"
}

}

这是子项目的build.gradle

    buildscript {
    repositories {
        jcenter()
        mavenCentral()
        maven {
            url "http://dl.bintray.com/twcable/aem"
        }
    }

    dependencies {
        classpath "com.twcable.gradle:gradle-plugin-cq-bundle:2.0.0"
        classpath "com.twcable.gradle:gradle-plugin-scr:1.0.1"

    }

}

apply plugin: "com.twcable.cq-bundle"
apply plugin: 'com.twcable.scr'

dependencies {
    compile "org.apache.commons:commons-io:1.3.2"
    compile "org.apache.commons:commons-lang3:3.0.1"
    compile "javax.servlet.jsp:jsp-api:2.2"
    compile "org.apache.sling:org.apache.sling.commons.json:2.0.10"
    compile "com.day.cq:cq-commons:5.8.2"
    compile "org.json:json:20151123"
    compile "com.day.cq.wcm:cq-wcm-api:5.7.2"
    compile "com.day.cq:cq-tagging:5.6.4"
    compile "org.apache.httpcomponents:httpcore:4.3.3"
    compile "org.apache.httpcomponents:httpclient:4.3.3"
    compile "com.adobe.granite:com.adobe.granite.fragment.xml:0.1.0"
    compile "commons-beanutils:commons-beanutils:1.9.2"
    compile "commons-digester:commons-digester:2.1"
    compile "commons-collections:commons-collections:3.2.2"
    compile "xpp3:xpp3:1.1.4c"
    compile "com.day.cq:cq-search:5.6.4"
    compile "cglib:cglib:3.2.0"
    compile "org.apache:jackrabbit-ocm:2.0.0"
    compile "org.jibx:jibx-run:1.2.6"
    compile "com.day.cq.dam:cq-dam-api:5.6.6"
    compile "com.adobe.granite:com.adobe.granite.replication.core:5.5.38"
    compile "com.day.cq.workflow:cq-workflow-api:5.6.2"
    compile "org.apache.sling:org.apache.sling.commons.osgi:2.2.2"
    compile "com.day.cq.dam:cq-dam-commons:5.8.2"
    compile "com.day.commons:day-commons-gfx:2.1.8"
    compile "org.apache.sling:org.apache.sling.commons.mime:2.1.8"
}

错误来自执行此插件的任务:

apply plugin: 'com.twcable.scr'

该插件位于github:https://github.com/TWCable/gradle-plugin-scr

1 个答案:

答案 0 :(得分:1)

插件问题跟踪器中存在一个问题需要讨论:https://github.com/TWCable/gradle-plugin-scr/issues/1