SpringCloud项目启动报错(Failed to instantiate SLF4J LoggerFactory)

一、控制台错误日志
这里截取控制台部分错误代码

 Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
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 java.lang.ClassLoader.loadClass(Unknown Source)
... 11 more
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/joran/spi/JoranException
at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150)

二、分析

1、无法实例化SLF4J LoggerFactory
报告的异常:
java.lang .NoClassDefFoundError:org / apache / log4j / Level
2、无法初始化类com.hp.hpl.jena.rdf.model.impl.ModelCom
org.slf4j.LoggerFactory.bind(LoggerFactory.java:128)

三、错误原因
You should also include log4j library as slf4j-log4j is just a static binder.
您还应该包含 log4j 库,因为 slf4j-log4j 只是一个静态绑定器。

四、解决:导入这两个依赖后启动正常

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.25</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/log4j/log4j -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>

你可能感兴趣的:(微服务相关的业务)