当前位置:   article > 正文

springboot项目启动时报错:Exception in thread “main“ java.lang.NoClassDefFoundError: org/slf4j/Logger......_exception in thread "main" java.lang.noclassdeffou

exception in thread "main" java.lang.noclassdeffounderror: org/slf4j/loggerf

一、错误信息如下:

Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/Logger
    at org.apache.logging.slf4j.SLF4JLoggerContext.getLogger(SLF4JLoggerContext.java:39)
    at org.apache.commons.logging.LogAdapter$Log4jLog.<init>(LogAdapter.java:165)
    at org.apache.commons.logging.LogAdapter$Log4jAdapter.createLog(LogAdapter.java:122)
    at org.apache.commons.logging.LogAdapter.createLog(LogAdapter.java:89)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:67)
    at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:59)
    at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:196)
    at com.zone.gateway.SigmaGatewayApplication.main(SigmaGatewayApplication.java:17)
Caused by: java.lang.ClassNotFoundException: org.slf4j.Logger
    at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    ... 8 more

 

 二、解决方法:

修改pom.xml中slf4j依赖配置:

原来:

  1. <dependency>
  2. <groupId>org.slf4j</groupId>
  3. <artifactId>slf4j-api</artifactId>
  4. <scope>provided</scope>
  5. </dependency>

 改为下面配置:

  1. <dependency>
  2. <groupId>org.slf4j</groupId>
  3. <artifactId>slf4j-api</artifactId>
  4. <version>1.7.25</version>
  5. </dependency>
  6. <!-- This is used for slf4j binding with log4j -->
  7. <dependency>
  8. <groupId>org.slf4j</groupId>
  9. <artifactId>slf4j-log4j12</artifactId>
  10. <version>1.7.25</version>
  11. <scope>test</scope>
  12. </dependency>

参考资料:

https://www.5axxw.com/questions/content/ve908qicon-default.png?t=N176https://www.5axxw.com/questions/content/ve908qidea环境配置如下: 

采用jdk11,启动正常。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/278864?site
推荐阅读
相关标签
  

闽ICP备14008679号