gpt4 book ai didi

log4j - 无法启动Spring Boot服务器

转载 作者:行者123 更新时间:2023-12-03 00:13:26 27 4
gpt4 key购买 nike

我是 Spring Boot 新手,当我尝试启动服务器时,出现以下异常。我知道这与依赖冲突有关,但仍然无法弄清楚。我正在使用 maven 来管理我的依赖项。请帮忙

 Exception in thread "main" 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) Object of class
[org.slf4j.impl.Log4jLoggerFactory] must be an instance of class
ch.qos.logback.classic.LoggerContext at
org.springframework.util.Assert.isInstanceOf(Assert.java:339) at
org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:93)
at
org.springframework.boot.logging.AbstractLoggingSystem.initializeWithSensibleDefaults(AbstractLoggingSystem.java:62)
at

org.springframework.boot.logging.AbstractLoggingSystem.beforeInitialize(AbstractLoggingSystem.java:45)
at

org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:69)
at

org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:135)
at

org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:98)
at

org.springframework.boot.context.event.EventPublishingRunListener.publishEvent(EventPublishingRunListener.java:100)
at

org.springframework.boot.context.event.EventPublishingRunListener.started(EventPublishingRunListener.java:54)
at

org.springframework.boot.SpringApplication.run(SpringApplication.java:276)
at

org.springframework.boot.SpringApplication.run(SpringApplication.java:952)
at

org.springframework.boot.SpringApplication.run(SpringApplication.java:941)
at org.magnum.mobilecloud.video.Application.main(Application.java:30)

已解决:将以下内容添加到 POM.xml

    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
</dependency>

最佳答案

spring-boot-starter-webspring-boot-starter-actuator 中排除 logback-classic> 为我工作

compile("org.springframework.boot:spring-boot-starter-web:1.1.10.RELEASE") {
exclude module: "spring-boot-starter-tomcat"
exclude module: "spring-boot-starter-logging"
exclude module: "logback-classic"
}
compile("org.springframework.boot:spring-boot-starter-actuator:1.1.10.RELEASE") {
exclude module: "logback-classic"
}

关于log4j - 无法启动Spring Boot服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26061860/

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