spring boot 启动报 java.lang.NoClassDefFoundError: ch/qos/logback/core/spi/LifeCycle 错误

Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: ch/qos/logback/core/spi/LifeCycle
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:)
at java.net.URLClassLoader.access$(URLClassLoader.java:)
at java.net.URLClassLoader$.run(URLClassLoader.java:)
at java.net.URLClassLoader$.run(URLClassLoader.java:)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:)
at java.lang.ClassLoader.loadClass(ClassLoader.java:)
at org.slf4j.impl.StaticLoggerBinder.<init>(StaticLoggerBinder.java:)
at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:)
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:)
at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:)
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:)
at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:)
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:)
at com.cfj.testboot.Application.main(Application.java:)

解决:这个问题的根本原因是类路径中不存在所需的jar。请添加以下依赖项——它们将解决您的问题。

再pom.xml中增加:

<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId> </exclusion>
</exclusions>
</dependency> <dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
上一篇:Cas 介绍及使用


下一篇:使用Json出现java.lang.NoClassDefFoundError解决方法