gpt4 book ai didi

java - 即使 StaticLoggerBinder 位于 Maven-Rep 中,也无法加载类 org.slf4j.impl.StaticLoggerBinder

转载 作者:行者123 更新时间:2023-12-02 01:44:01 26 4
gpt4 key购买 nike

我尝试使用 slf4j-Logger-Functions 但总是遇到相同的错误:

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.

我已经尝试了常见的解决方案,如图所示,“StaticLoggerBinder”已加载到目录中,但错误仍然存​​在。你知道为什么吗?

package de.stefan.test;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class Test {

public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(Test.class);
logger.info("This is how you configure Java Logging with SLF4J");
}
}

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>de.stefan</groupId>
<artifactId>stefan</artifactId>
<version>1.0-SNAPSHOT</version>

<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>

</dependencies>

</project>

Project structure

最佳答案

当您运行程序时,

slf4j-simple 不是您的类路径。将其放入您的类路径中,例如 java -classpath ./lib/* YourProgram。其中 lib 包含您的 jar 文件。

关于java - 即使 StaticLoggerBinder 位于 Maven-Rep 中,也无法加载类 org.slf4j.impl.StaticLoggerBinder,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57473745/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com