I'm getting “NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil”

眉间皱痕 提交于 2019-12-05 08:11:10

The error: java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil

is because log4j2 since version 2.9.0 has been removed that class from api jar (log4j-api-2.x.x.jar).

The last version that has it, is 2.8.2

Probably you have mixed versions in the classpath.

Correct way to configure log4j2 in spring boot is like this:

dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.boot:spring-boot-starter-log4j2'
}

configurations {
    all {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
}

It's explained in the documentation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!