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

后端 未结 2 1238
庸人自扰
庸人自扰 2021-01-04 02:36

I have the following dependencies in my build.gradle file.

compile \'org.slf4j:slf4j-api:1.7.25\'
compile group: \'org.apache.logging.log4j\', name: \'log4j-         


        
相关标签:
2条回答
  • 2021-01-04 02:39

    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.

    0 讨论(0)
  • 2021-01-04 02:54

    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.

    0 讨论(0)
提交回复
热议问题