当前位置: 首页 > 知识库问答 >
问题:

SLF4J:类路径包含多个SLF4J绑定。多个日志-经典JAR

马俊
2023-03-14

SLF4J:类路径包含多个SLF4J绑定。

SLF4J:在[jar:file:/c:/myproject/gradle-2.3-all/gradle-2.3/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/statloggerbinder.class]中找到绑定

SLF4J:在[jar:file:/c:/myproject/myproject/build/temp/tomcatrunwar/work/tomcat/localhost/myproject/web-inf/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/statloggerbinder.class]中找到绑定

SLF4J:实际绑定的类型为[ch.qos.logback.classic.util.ContextSelectorStaticBinder]

以下是我的依赖关系:

buildscript {
repositories {
    maven { url "http://repo.spring.io/libs-release" }
    mavenLocal()
}
dependencies {
    classpath("org.springframework.boot:spring-boot-gradle-plugin:1.0.1.RELEASE")
    classpath 'org.gradle.api.plugins:gradle-tomcat-plugin:1.2.4'
}} 

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'spring-boot'
apply plugin: 'war'
apply plugin: 'groovy'
apply plugin: 'tomcat'


eclipse {
jdt {
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
}}

jar {
baseName = 'myproject'
version =  '0.1.0' }

repositories {
mavenCentral()
maven { url "http://repo.spring.io/libs-release" } }

dependencies {
compile('commons-fileupload:commons-fileupload:1.3.1')
compile("org.codehaus.jackson:jackson-html" target="_blank">mapper-asl:1.9.0")
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.data:spring-data-mongodb")
compile("org.springframework.security:spring-security-crypto:3.2.3.RELEASE")
compile("com.fasterxml.jackson.core:jackson-databind")
compile("joda-time:joda-time:2.2")
compile("org.apache.directory.studio:org.apache.commons.codec:1.6")
compile('com.amazonaws:aws-java-sdk:1.2.1')
testCompile("junit:junit")
    runtime 'javax.servlet:jstl:1.2'
providedCompile group:"org.apache.tomcat", name:"tomcat-catalina", version:"7.0.47" }


dependencies { 
def tomcatVersion = '7.0.47' 
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}", 
"org.apache.tomcat.embed:tomcat-embed-logging-log4j:${tomcatVersion}" 
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") { 
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj' 
} }


tomcatRun { daemon = true 
httpPort = 8080
outputFile = file('/logs/tomcat.log')
stopKey = 'ctl-d'
webDefaultXml = file('src/main/webapp/WEB-INF/web.xml')  }

 tomcatRunWar { outputFile = file('/logs/tomcat.log')  }
tomcatStop { stopKey = 'ctl-d'  }

共有1个答案

王曜文
2023-03-14

首先在命令行上执行以下操作:

gradle dependencies > foo.txt

喝完咖啡去吧。结果文件将包含完整的依赖关系树。搜索日志。

然后,当您修改构建文件时,据我所知(我也是gradle的新手),您只需要排除模块或组中的任何一个,而不是同时排除两个。组基本上是冒号前面的部分,模块是后面的部分。

"org.apache.tomcat.embed:tomcat-embed-logging-log4j:${tomcatVersion}"
 类似资料: