gradle BOM -SLF 4J:未找到SLF 4J提供程序

gblwokeq  于 12个月前  发布在  其他
关注(0)|答案(1)|浏览(101)

此处构建.gradle.kts

dependencies {
  
    implementation("org.apache.logging.log4j:log4j-api:2.12.4")
    implementation("org.apache.logging.log4j:log4j-core:2.12.4")
    implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.12.4")

    testImplementation("org.junit.jupiter:junit-jupiter:5.9.3")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

字符串
运行我的java应用程序如下:

./gradlew run


而且它的工作刚刚好。

2023-12-14 19:45:45 DEBUG App:21 - current date = 2023-12-14T19:45:45.699


不错啊
现在我想使用Spring BOM,所以在这里build.gradle.kts

dependencies {
    implementation(enforcedPlatform("org.springframework.boot:spring-boot-dependencies:3.1.2"))

    implementation("org.apache.logging.log4j:log4j-api")
    implementation("org.apache.logging.log4j:log4j-core")
    implementation("org.apache.logging.log4j:log4j-slf4j-impl")

    testImplementation("org.junit.jupiter:junit-jupiter")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}


但是现在当我使用这个命令时:

./gradlew run


上升误差:

SLF4J: No SLF4J providers were found.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
SLF4J: Class path contains SLF4J bindings targeting slf4j-api versions 1.7.x or earlier.
SLF4J: Ignoring binding found at [jar:file:/home/myhost/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.20.0/7ab4f082fd162f60afcaf2b8744a3d959feab3e8/log4j-slf4j-impl-2.20.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See https://www.slf4j.org/codes.html#ignoredBindings for an explanation.

jchrr9hc

jchrr9hc1#

我找到了解决方案:

dependencies {
    implementation(platform("org.springframework.boot:spring-boot-dependencies:3.2.0"))

    implementation("org.slf4j:slf4j-api")
    implementation("org.apache.logging.log4j:log4j-slf4j2-impl")
}

字符串

相关问题