gpt4 book ai didi

spring-boot - Spring Boot-我可以将Jetty与SL4J一起使用

转载 作者:行者123 更新时间:2023-12-03 05:47:31 24 4
gpt4 key购买 nike

我正在开发SpringBoot-Kotlin-Gradle项目,但似乎遇到了记录程序冲突。我正在使用一个包含slf4j的库-因此,在启动时,我得到了如下奇妙的信息:

Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.impl.Log4jLoggerFactory loaded from file:/Users/USERNAME/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.25/110cefe2df103412849d72ef7a67e4e91e4266b4/slf4j-log4j12-1.7.25.jar). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.impl.Log4jLoggerFactory



将这些行添加到我的 build.gradle文件中可以运行:
configurations {
providedRuntime
compile.exclude(group: 'ch.qos.logback')
}

但是,我的应用程序现在以 Tomcat 而不是 Jetty 来启动。

我的依赖项是:
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
compile("org.jetbrains.kotlin:kotlin-reflect")
compile 'org.springframework.boot:spring-boot-starter-web'
runtime('org.springframework.boot:spring-boot-devtools')
testCompile('org.springframework.boot:spring-boot-starter-test')


//SpringFox
compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.8.0'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.8.0'
compile group: 'io.springfox', name: 'springfox-spring-web', version: '2.8.0'

// SDDF
compile "org.mitre.sddf:sddf:15.3.2"
}

有没有一种简单的方法可以解决此问题,并且仍然能够使用 Jetty

我可以在 applicaiton.ymlapplictaion.properties中放一些东西吗?

最佳答案

好吧,看来我设法弄清楚了我的问题(通过仔细阅读日志)

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/jstein/.gradle/caches/modules-2/files-2.1/org.slf4j/slf4j-log4j12/1.7.25/110cefe2df103412849d72ef7a67e4e91e4266b4/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/jstein/.gradle/caches/modules-2/files-2.1/ch.qos.logback/logback-classic/1.2.3/7c4f3c474fb2c041d8028740440937705ebb473a/logback-classic-1.2.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]

我将此添加到了 build.gradle
configurations.all {
exclude group: 'org.slf4j', module: 'slf4j-log4j12'
}

关于spring-boot - Spring Boot-我可以将Jetty与SL4J一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49197288/

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