我收到以下错误,但无法找出原因:
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)}
提前致谢!
答案 0 :(得分:0)
Springboot仍然需要某种日志框架才能运行。如果排除了默认值,则需要将其替换为其他内容。 希望这会有所帮助:https://github.com/spring-projects/spring-boot/issues/8492