[英]SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" error
I am running my app with Maven. But I get an error:我正在使用 Maven 运行我的应用程序。但出现错误:
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.
App uses log4j:应用程序使用 log4j:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class App {
public static void main(String[] args) {
Logger logger = LoggerFactory.getLogger(App.class);
logger.info("Test 1,2,3");
System.out.println("End of my program");
}
}
pom.xml file includes next dependencies: pom.xml 文件包括下一个依赖项:
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope>
</dependency>
How to solve this problem?如何解决这个问题呢? I checked solutions in google but it doesnt help...
我在谷歌中检查了解决方案,但它没有帮助......
I tried to add implepentation for example slf4j-simple but nothing changed我尝试添加实现,例如 slf4j-simple 但没有任何改变
The solution did not need to test scope in Slf4j Dependencies because it is probably not available when you run your main method.该解决方案不需要在 Slf4j 依赖项中测试 scope ,因为当您运行 main 方法时它可能不可用。
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<scope>test</scope> //Remove the test scope
</dependency>
Then it's working fine without any errors.然后它工作正常,没有任何错误。
Thanks.谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.