gpt4 book ai didi

java - SLF4J : Class path contains multiple SLF4J bindings. 多个 logback-classic jar

转载 作者:行者123 更新时间:2023-12-02 04:33:12 25 4
gpt4 key购买 nike

我正在使用 gradle 构建并运行 Spring Web 应用程序。有多种绑定(bind)。阅读现有的帖子,我发现了很多类似的问题。但我有两个问题。 (1) 我找不到冲突依赖项。 (2)我对gradle语法不太熟悉。所以我尝试了很多方法。但还是很困惑。欢迎任何帮助。谢谢。这是错误:

SLF4J: Class path contains multiple SLF4J bindings.

SLF4j: Found bindings in [jar:file:/C:/myproject/gradle-2.3-all/gradle-2.3/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StatLoggerBinder.class]

SLF4j: Found bindings in [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: Actual binding is of type [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-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' }

最佳答案

首先在命令行上执行此操作:

gradle dependencies > foo.txt

完成后去喝咖啡。生成的文件将包含完整的依赖关系树。搜索logback。

然后,当你修改构建文件时,据我所知(我在 gradle 方面也比较新),你只需要排除模块或组,而不是两者都排除。组基本上是冒号之前的部分,模块是冒号之后的部分。

再次查看错误的详细信息,我认为问题可能包含在此处:

"org.apache.tomcat.embed:tomcat-embed-logging-log4j:${tomcatVersion}"

所以我认为您应该将其分解为自己的行/依赖项并将排除项放在那里。

关于java - SLF4J : Class path contains multiple SLF4J bindings. 多个 logback-classic jar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31173680/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com