java.lang.IllegalArgumentException:LoggerFactory 不是 Logback LoggerContext 但 Logback 位于类路径上
当我构建项目时,我收到以下错误,我尝试了各种其他 StackOverflow 答案,但都是徒劳。
还尝试从所有依赖项中排除 logback
,
configurations {
implementation {
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
}
上面确实解决了问题,但给出了另一个错误 java.lang.NoClassDefFoundError: ch/qos/logback/classic/turbo/TurboFilter ,似乎它在其他地方使用
logback
,因此不能从所有依赖项中排除 logback
。任何关于如何解决这个问题的建议都非常有价值。谢谢。
错误日志
引起:java.lang.IllegalArgumentException:LoggerFactory 不是 Logback LoggerContext 但 Logback 位于类路径上。要么删除 Logback 或竞争的实现(类 org.jboss.slf4j.JBossLoggerFactory 加载自 文件:/C:/Users/idnpga/.gradle/caches/modules-2/files-2.1/org.infinispan/infinispan-embedded/9.1.7.Final/6b94fd0e5872b8ce90ab35531afe90d1efaf36f0/infinispan-embedded-9.1.7.Final.jar )。 如果您使用 WebLogic,则需要将“org.slf4j”添加到 WEB-INF/weblogic.xml 中的首选应用程序包: org.jboss.slf4j.JBossLoggerFactory 位于 org.springframework.util.Assert.instanceCheckFailed(Assert.java:696) 在 org.springframework.util.Assert.isInstanceOf(Assert.java:596) 处 org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:284) 在 org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:104) 在 org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:232) 在 org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) 在 org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) 在 org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:74) 在 org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47) 在 org.springframework.boot.SpringApplication.run(SpringApplication.java:305) 在 org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120) 在 org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) 在 org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124) ... 81 更多
build.gradle
dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-amqp')
implementation('org.springframework.boot:spring-boot-starter-data-mongodb')
implementation('org.springframework.boot:spring-boot-starter-data-rest')
implementation('org.springframework.boot:spring-boot-starter-integration')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-thymeleaf') {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-web-services')
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-config', version: '2.0.5.RELEASE'
implementation('org.springframework.data:spring-data-rest-hal-explorer')
implementation('org.springframework.integration:spring-integration-amqp')
implementation('org.springframework.integration:spring-integration-mongodb')
implementation('org.springframework.integration:spring-integration-file')
implementation('org.springframework.integration:spring-integration-http')
implementation('org.springframework.integration:spring-integration-ip')
implementation('org.springframework.integration:spring-integration-sftp')
implementation('org.springframework.integration:spring-integration-stream')
implementation('org.springframework.integration:spring-integration-xml')
implementation('org.springframework.ws:spring-ws-security') {
exclude group: 'org.opensaml:opensaml-saml-impl'
}
implementation ('org.springframework.security:spring-security-oauth2-core') {
exclude group: 'org.codehaus.jackson'
}
implementation group: 'org.springframework.data', name: 'spring-data-mongodb', version: '3.0.4.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.1.5.RELEASE'
implementation 'org.infinispan:infinispan-spring-boot-starter-parent:14.0.0.Dev01'
implementation 'org.infinispan:spring-boot-starter-infinispan-autoconfigure:1.0.0'
implementation('org.infinispan:infinispan-embedded:9.1.7.Final')
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.9'
testImplementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.9'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module : 'junit-vintage-engine'
}
testImplementation('org.springframework.ws:spring-ws-test')
testImplementation("org.springframework.cloud:spring-cloud-contract-wiremock:3.1.1")
testImplementation("org.springframework.cloud:spring-cloud-starter-contract-verifier") {
exclude group: 'org.springframework.boot', module : 'spring-boot-starter-test'
}
}
I am getting the following error when I build my project, I tried various other StackOverflow answers but all in vain.
Also tried to exclude logback
from all the dependencies,
configurations {
implementation {
exclude group: 'ch.qos.logback', module: 'logback-classic'
}
}
And the above does solve the problem but gives another error java.lang.NoClassDefFoundError: ch/qos/logback/classic/turbo/TurboFilter
, seems like it is using logback
some place else and hence logback
cannot be excluded from all the dependencies. Any suggestion on how to get rid of the issue would be really valuable. Thanks.
Error log
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.jboss.slf4j.JBossLoggerFactory loaded from
file:/C:/Users/idnpga/.gradle/caches/modules-2/files-2.1/org.infinispan/infinispan-embedded/9.1.7.Final/6b94fd0e5872b8ce90ab35531afe90d1efaf36f0/infinispan-embedded-9.1.7.Final.jar).
If you are using WebLogic you will need to add 'org.slf4j' to
prefer-application-packages in WEB-INF/weblogic.xml:
org.jboss.slf4j.JBossLoggerFactory at
org.springframework.util.Assert.instanceCheckFailed(Assert.java:696)
at org.springframework.util.Assert.isInstanceOf(Assert.java:596) at
org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:284)
at
org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:104)
at
org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:232)
at
org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:213)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
at
org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
at
org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:74)
at
org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:47)
at
org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
at
org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:120)
at
org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
at
org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:124)
... 81 more
build.gradle
dependencies {
implementation('org.springframework.boot:spring-boot-starter-actuator')
implementation('org.springframework.boot:spring-boot-starter-amqp')
implementation('org.springframework.boot:spring-boot-starter-data-mongodb')
implementation('org.springframework.boot:spring-boot-starter-data-rest')
implementation('org.springframework.boot:spring-boot-starter-integration')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-thymeleaf') {
exclude group: 'org.codehaus.groovy', module: 'groovy'
}
implementation('org.springframework.boot:spring-boot-starter-web')
implementation('org.springframework.boot:spring-boot-starter-web-services')
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-config', version: '2.0.5.RELEASE'
implementation('org.springframework.data:spring-data-rest-hal-explorer')
implementation('org.springframework.integration:spring-integration-amqp')
implementation('org.springframework.integration:spring-integration-mongodb')
implementation('org.springframework.integration:spring-integration-file')
implementation('org.springframework.integration:spring-integration-http')
implementation('org.springframework.integration:spring-integration-ip')
implementation('org.springframework.integration:spring-integration-sftp')
implementation('org.springframework.integration:spring-integration-stream')
implementation('org.springframework.integration:spring-integration-xml')
implementation('org.springframework.ws:spring-ws-security') {
exclude group: 'org.opensaml:opensaml-saml-impl'
}
implementation ('org.springframework.security:spring-security-oauth2-core') {
exclude group: 'org.codehaus.jackson'
}
implementation group: 'org.springframework.data', name: 'spring-data-mongodb', version: '3.0.4.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation group: 'org.springframework.cloud', name: 'spring-cloud-starter-netflix-hystrix', version: '2.1.5.RELEASE'
implementation 'org.infinispan:infinispan-spring-boot-starter-parent:14.0.0.Dev01'
implementation 'org.infinispan:spring-boot-starter-infinispan-autoconfigure:1.0.0'
implementation('org.infinispan:infinispan-embedded:9.1.7.Final')
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.9'
testImplementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.9'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module : 'junit-vintage-engine'
}
testImplementation('org.springframework.ws:spring-ws-test')
testImplementation("org.springframework.cloud:spring-cloud-contract-wiremock:3.1.1")
testImplementation("org.springframework.cloud:spring-cloud-starter-contract-verifier") {
exclude group: 'org.springframework.boot', module : 'spring-boot-starter-test'
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论