解决SLF4J报Failed to load class “org.slf4j.impl.StaticLoggerBinder
解决SLF4J报Failed to load class "org.slf4j.impl.StaticLoggerBinder"和 Defaulting to no-operation (NOP) logger implementation
·
解决SLF4J报Failed to load class "org.slf4j.impl.StaticLoggerBinder"和 Defaulting to no-operation (NOP) logger implementation
错误原因:这个错误通常出现在应用程序中未包含 SLF4J 的实现(如 Log4j、Logback 等)或者 SLF4J 实现的 JAR 包没有正确添加到类路径中。SLF4J 需要一个实际的日志框架作为后端来处理日志消息,而如果找不到这个后端,就会导致上述错误。
错误提示:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See SLF4J Error Codes for further details.
解决方法:导入SLF4J的maven依赖:
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-api</artifactId> <version>${slf4j.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple--> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>${slf4j.version}</version> <!-- 注意,若无type为jar则报错--> <type>jar</type> </dependency>
更多推荐
所有评论(0)