运行Maven项目时,控制台出现如下图所示的报错信息:
在这里插入图片描述
问题分析:
根据报错提示,我们可以知道出错的原因是“加载类文件org.slf4j.impl.StaticLoggerBinder时失败”,而出错的地方主要是在于slf4j的jar包。

官网给出的解决思路如下:
This error is reported when the org.slf4j.impl.StaticLoggerBinder class could not be loaded into memory. This happens when no appropriate SLF4J binding could be found on the class path. Placing one (and only one) of slf4j-nop.jar, slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar or logback-classic.jar on the class path should solve the problem.

翻译成汉语如下(我是直接英汉互译翻译过来的):
此错误在组织slf4j.inf.strestcoperbinder类无法装入内存时报告。当在类路径上找不到合适的slf4j绑定时,就会发生这种情况。slf4j-nop.jar放置一个(且只有一个), slf4j-simple.jar, slf4j-log4j12.jar, slf4j-jdk14.jar 或 logback-classic.jar 的类路径应该解决这个问题。

解决方案:
在Maven工程的pom文件中,新增一个上述的包文件之一的依赖配置,项目就可以正常编译运行了。

<dependency>  
  <groupId>org.slf4j</groupId> 
  <artifactId>slf4j-nop</artifactId> 
  <version>1.7.2</version> 
</dependency>
Logo

脑启社区是一个专注类脑智能领域的开发者社区。欢迎加入社区,共建类脑智能生态。社区为开发者提供了丰富的开源类脑工具软件、类脑算法模型及数据集、类脑知识库、类脑技术培训课程以及类脑应用案例等资源。

更多推荐