Spring boot 1.5.8默认提供logback-1.1.11版本。 我正在尝试将Logback版本从1.1.11升级到1.3.0-alpha4,并在pom中添加了以下两个属性。
<slf4j.version>1.8.0-beta4</slf4j.version>
<logback.version>1.3.0-alpha4</logback.version>
当我尝试运行该应用程序时,出现以下异常。
Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
at org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:273)
at org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:98)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:230)
at org.springframework.boot.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:209)
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:122)
at org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:69)
at org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:48)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:292)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1107)
at com.anthem.acmp.service.UMIDALServiceApplication.main(UMIDALServiceApplication.java:25)
Caused by: java.lang.ClassNotFoundException: org.slf4j.impl.StaticLoggerBinder
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 14 more
我发现logback-classic-1.1.11.jar包含一个包org.slf4j.impl,该包的类为StaticLoggerBinder,在logback-classic-1.3.0-alpha4中不可用,并导致此问题。
答案 0 :(得分:0)
Logback 1.3和SLF4J 1.8分别与它们的1.2和1.7版本相比具有重大的API更改。在撰写本文时,Spring Boot与新API不兼容。有issue正在跟踪对新版本的支持。在项目稳定并且不再处于alpha或beta状态之前,不会解决该问题。
答案 1 :(得分:0)
当我将 StaticLoggerBinder from version 1.2 复制到我的项目中时,我能够使用 logback 1.3.0-alpha4。 (在新包 item
中创建一个新的 <form>
并粘贴整个文件。)