【发布时间】:2015-08-12 22:30:48
【问题描述】:
我正在尝试在 Spring Boot 项目中使用 Betamax 的最新(主)版本,我收到了错误 SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError.。
所以我查看了this question 的最佳答案,它说通过这样做来排除冲突依赖项:
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
但我的项目使用的是 Gradle,所以我必须将其转换为 Gradle,我真的不知道我在做什么。我看着this post 并尝试像这样搞砸它
dependencies {
...
compile('org.slf4j') {
exclude module: 'slf4j-log4j12'
}
}
但似乎没有任何效果。谁能帮我找出正确的语法?非常感谢任何帮助。
如果它有帮助的话,我的依赖块目前看起来像这样:
dependencies {
testCompile 'org.springframework.boot:spring-boot-starter-test:1.2.1.RELEASE'
testCompile 'org.codehaus.groovy:groovy-all:2.3.3'
testCompile 'co.freeside.betamax:betamax-proxy:2.0-SNAPSHOT'
testCompile 'co.freeside.betamax:betamax-junit:2.0-SNAPSHOT'
compile 'org.springframework.boot:spring-boot-starter-log4j2:1.2.1.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-web:1.2.1.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-data-jpa:1.2.1.RELEASE'
compile 'org.springframework.boot:spring-boot-starter-tomcat:1.2.1.RELEASE'
compile 'org.apache.tomcat.embed:tomcat-embed-jasper'
compile 'com.domingosuarez.boot:spring-boot-starter-jade4j:0.2'
compile 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.4.0'
compile 'com.mashape.unirest:unirest-java:1.4.5'
runtime 'mysql:mysql-connector-java:5.1.34'
runtime 'net.kencochrane.raven:raven-log4j2:6.0.0'
}
【问题讨论】:
-
slf4j-log4j12 中的依赖是什么?我没看到。无论如何,这是您要排除的依赖项(不是 org.slf4j)。比如是raven-log4j2,那么
runtime('net.kencochrane.raven:raven-log4j2:6.0.0') { exclude module: 'slf4j-log4j12' } -
@DonBottstein,这行得通。谢谢!
标签: java maven gradle spring-boot betamax