gpt4 book ai didi

spring-boot - ClassNotFoundException : org. slf4j.impl.StaticLoggerBinder

转载 作者:行者123 更新时间:2023-12-01 23:27:49 24 4
gpt4 key购买 nike

我正在将 spring 应用程序转换为 spring-boot,使用 boot-starter-parent 版本:2.0.4.RELEASE。当我使用
mvn install,它运行良好,但是当我尝试使用以下命令运行应用程序时:mvn spring-boot:run -Dspring.profiles.active=dev ,我收到此异常:
ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder

这是我的 pom 中的依赖项:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
</parent>

<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.24</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.3.0-alpha4</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.3.0-alpha4</version>
</dependency>
</dependencies>

我尝试遵循 this question 的建议,并使用新旧版本的 logback(核心和经典)依赖项,并添加“slf4j-log4j12”和“slf4j-simple”,但仍然出现异常。堆栈跟踪是:

java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext (LogbackLoggingSystem.java:285) at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize (LogbackLoggingSystem.java:102) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent (LoggingApplicationListener.java:191) at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent (LoggingApplicationListener.java:170) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener (SimpleApplicationEventMulticaster.java:167) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java:139) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java:122) at org.springframework.boot.context.event.EventPublishingRunListener.starting (EventPublishingRunListener.java:68) at org.springframework.boot.SpringApplicationRunListeners.starting (SpringApplicationRunListeners.java:48) at org.springframework.boot.SpringApplication.run (SpringApplication.java:316) at org.springframework.boot.SpringApplication.run (SpringApplication.java:1258) at org.springframework.boot.SpringApplication.run (SpringApplication.java:1246) at com.hbo.esp.MyApplication.main (MyApplication.java:17) at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

最佳答案

尝试按如下方式更改每个依赖项的版本。

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>

希望这可以帮助。

关于spring-boot - ClassNotFoundException : org. slf4j.impl.StaticLoggerBinder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52322027/

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