728x90
1. 에러명
java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder
SchedulerApplicationTests > contextLoads() FAILED
java.lang.NoClassDefFoundError at LogbackLoggingSystem.java:293
Caused by: java.lang.ClassNotFoundException at BuiltinClassLoader.java:581
보통 ContextLoads() error는 mysql 연결안될때 많이 발생하던데 나는 Logback을 설치하고 나서부터 에러가 발생하였다.
2. 해결방법
build.gradle
dependencies{
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.0'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
implementation 'com.google.code.gson:gson:2.9.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework:spring-webflux:5.3.23'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'mysql:mysql-connector-java'
testImplementation 'ch.qos.logback:logback-classic:1.4.4'
implementation 'org.slf4j:jcl-over-slf4j:2.0.3'.
implementation 'org.slf4j:slf4j-api:1.7.5'
// 추가한 library
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.slf4j:slf4j-simple:1.7.25'
}
3. 새로운 error
다른 에러가 발생했다.
SchedulerApplicationTests > contextLoads() FAILED
java.lang.IllegalStateException at DefaultCacheAwareContextLoaderDelegate.java:132
Caused by: java.lang.IllegalArgumentException at Assert.java:702
4. 진짜 해결
음 에러로그를 중간쯤 읽다보니 Slf4j 나 Loggerback 둘중에 하나를 삭제하라는 메시지를 발견했다.
아무래도 충돌하는것같다. 원래 같이 쓰면 안되나..?
Springboot 가 기본적으로 Slf4j를 가지고 있기 때문에 아무래도 그런거같다.
그래서 dependencies 에서 logback삭제해주었더니 잘 되었다.!!!
dependencies {
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.14.0'
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'com.google.code.gson:gson:2.9.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework:spring-webflux:5.3.23'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
runtimeOnly 'mysql:mysql-connector-java'
implementation 'org.slf4j:slf4j-api:1.7.5'
implementation 'org.slf4j:jcl-over-slf4j:2.0.3'
}
Reference
https://applepick.tistory.com/134
https://donzbox.tistory.com/601
반응형
댓글