没有查看springboot各个版本包集成,纯小白面向百度/优快云编程,在按照网上套路进行整合后出现异常。
异常代码
SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions prior to 1.8.
SLF4J: Ignoring binding found at [jar:file:/F:/apache-maven-3.8.5/localRepository/ch/qos/logback/logback-classic/1.2.11/logback-classic-1.2.11.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#ignoredBindings for an explanation.
包环境
springboot 2.6.7
slf4j引用版本见下方代码
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0-alpha7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.0-alpha7</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
解决
注释/删除 以下slf4j 的引用
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0-alpha7</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>2.0.0-alpha7</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
随后DEMO正常,似乎在springboot某版本开始已经集成sfl4j
参考
-
安装
SpringBoot系列(6):SpringBoot集成slf4j日志配置_洒家肉山大魔王的博客-优快云博客_springboot集成slf4j
-
解决灵感
SpringBoot之@Slf4j的使用详解_gcglhd的博客-优快云博客_springboot使用slf4j
SLF4J: No SLF4J providers were found. - 程序员大本营 (pianshen.com)
完美解决项目No SLF4J providers were found.错误_重写小林的博客-优快云博客
springboot 出现 Class path contains multiple SLF4J bindings.警告的解决办法_不想穿格子衫的博客-优快云博客
-
使用
-
技巧
springboot 动态指定日志路径(logback) 自动跟随项目路径_王王山而广隶的博客-优快云博客_springboot指定logback路径

在尝试将SFL4J与SpringBoot 2.6.7整合时遇到警告问题,通过注释或删除特定引用解决了冲突。原来从某个SpringBoot版本开始已内置SFL4J。参考了多个博客文章找到解决方法。
3万+

被折叠的 条评论
为什么被折叠?



