【问题标题】:Problem with error SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder"错误 SLF4J 的问题:无法加载类“org.slf4j.impl.StaticLoggerBinder”
【发布时间】:2021-05-08 03:43:52
【问题描述】:

您好,我遇到了简单代码的问题。我想尝试在这段代码中使用 slf4j

public class App {
public static void main(String[] args) {
    var logger = LoggerFactory.getLogger(App.class);
    logger.info("Hello World!");
}

但我有一个错误

SLF4J:无法加载类“org.slf4j.impl.StaticLoggerBinder”。 SLF4J:默认为无操作(NOP)记录器实现 SLF4J:详情请见http://www.slf4j.org/codes.html#StaticLoggerBinder

你能帮帮我吗?

【问题讨论】:

  • 您的项目中有哪些依赖项?请分享 pom.xml。
  • junitjunit${junit.version}testorg.slf4jslf4j-api${slf4j.version}org.slf4j groupId> slf4j-simple${slf4j.version}test

标签: intellij-idea maven-3 java-11


【解决方案1】:

slf4j-simple 依赖项中删除 <scope>test</scope> 并在 IDE 中刷新 Maven 项目。在test 范围内,依赖项仅适用于src/test/java 中的代码,不适用于src/main/java 中的主应用程序生产代码。

【讨论】:

猜你喜欢
  • 2012-08-08
  • 1970-01-01
  • 1970-01-01
  • 2011-11-17
  • 2017-07-24
  • 1970-01-01
  • 2020-03-20
相关资源
最近更新 更多