Springboot - 我可以将 Jetty 与 SL4J 一起使用吗
Springboot - Can i use Jetty with SL4J
我正在开发一个 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.yml
或 applictaion.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'
}
我正在开发一个 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.yml
或 applictaion.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'
}