Failed to instantiate SLF4J LoggerFactoryReported exception:java.lang.NoClassDefFoundError: ch/qos/logback/core/spi/LifeCycle at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(ClassLoader.java:763) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) at java.net.URLClassLoader.access$100(URLClassLoader.java:73) at java.net.URLClassLoader$1.run(URLClassLoader.java:368) at java.net.URLClassLoader$1.run(URLClassLoader.java:362) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:361) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at org.slf4j.impl.StaticLoggerBinder.(StaticLoggerBinder.java:59) at org.slf4j.impl.StaticLoggerBinder. (StaticLoggerBinder.java:50) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:412) at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:155) at org.apache.commons.logging.impl.SLF4JLogFactory.getInstance(SLF4JLogFactory.java:132) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:273) at org.springframework.boot.SpringApplication. (SpringApplication.java:179) at com.cfj.testboot.Application.main(Application.java:19)
解决:这个问题的根本原因是类路径中不存在所需的jar。请添加以下依赖项——它们将解决您的问题。
再pom.xml中增加:
ch.qos.logback logback-classic 1.2.3 ch.qos.logback logback-classic 1.2.3 org.slf4j slf4j-log4j12 ch.qos.logback logback-core 1.2.3