我收到以下错误,我不知道为什么:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.boot.SpringApplication.<clinit>(SpringApplication.java:179)
at ro.schedulerbot.app_starter.SchedulerBotApplication.main(SchedulerBotApplication.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

在这里,我将 log4j 设置为使用的日志记录框架:
dependencies {
    //LOG4J
    compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.9.1'
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.9.1'
}

这是我的排除方法的样子:
ext.excludeDefaultLogger = {
exclude group: "commons-logging", module: "commons-logging"
exclude module: "spring-boot-starter-logging"}

这就是我添加spring依赖项的方式:
dependencies {
//  SPRING
compile('org.springframework.boot:spring-boot-starter-web:1.5.10.RELEASE', excludeDefaultLogger)}

提前致谢!

最佳答案

Spring Boot仍需要某种日志记录框架才能运行。如果排除了默认值,则需要用其他替换它。
希望这会有所帮助:ojita

10-07 19:31
查看更多