build.gradle添加implementation libs.slf4jApi
报以下错,解决方案:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
在build.gradle的子项目core中需要添加这两个依赖:
project(':core') {
println "Building project 'core' with Scala version ${versions.scala}"
...
dependencies {
...
// 添加以下两个依赖
// https://mvnrepository.com/artifact/org.slf4j/slf4j-api
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
// https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.25'
}
解决SLF4J加载StaticLoggerBinder失败问题
在构建项目时遇到了SLF4J未能加载'org.slf4j.impl.StaticLoggerBinder'的错误,导致默认初始化为无操作日志器。为了解决这个问题,在子项目core的build.gradle中需添加两个依赖:slf4j-api和slf4j-log4j12,版本均为1.7.25。这样可以确保SLF4J正确绑定到Log4j实现,从而正常记录日志。
1615

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



