programing

"NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil"이라고 표시됩니다.

madecode 2023. 3. 9. 22:35
반응형

"NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil"이라고 표시됩니다.

내 build.gradle 파일에는 다음과 같은 종속성이 있습니다.

compile 'org.slf4j:slf4j-api:1.7.25'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.1'

유닛 테스트를 실행하면 다음 로그가 표시됩니다.

exclude patterns:SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in 
[jar:file:....gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.7/382b070836b8940a02d28c936974db95e9bfc3a4/log4j-slf4j-impl-2.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/z002qz1/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-slf4j-impl/2.9.1/a97a849b18b3798c4af1a2ca5b10c66cef17e3a/log4j-slf4j-impl-2.9.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil
at org.apache.logging.slf4j.Log4jLoggerFactory.getContext(Log4jLoggerFactory.java:42)
at org.apache.logging.log4j.spi.AbstractLoggerAdapter.getLogger(AbstractLoggerAdapter.java:46)
at org.apache.logging.slf4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:29)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:358)

springboot 2.0.4를 사용하고 있습니다.풀어주다.그냥 버전 불일치 문제였으면 좋겠어요.모든 통찰에 감사드립니다.

오류:java.lang.NoClassDefFoundError: org/apache/logging/log4j/util/ReflectionUtil

이는 버전 2.9.0 이후의 log4j2가 API jar(log4j-api-2.x.jar)에서 해당 클래스가 삭제되었기 때문입니다.

마지막으로 탑재된 버전은 2.8.2 입니다.

클래스 패스에 혼재된 버전이 있을 수 있습니다.

스프링 부트에서의 log4j2 의 올바른 설정 방법은 다음과 같습니다.

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'
    }
}

서류에 설명되어 있습니다.

언급URL : https://stackoverflow.com/questions/52700803/im-getting-noclassdeffounderror-org-apache-logging-log4j-util-reflectionutil

반응형