티스토리 뷰
Kotlin & JPA
[Kotlin] ./gradlew build 시 Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation 에러 해결
Jane Kwon 2023. 7. 3. 17:21반응형
로컬에선 잘 동작하더니 ECR로 올려서 App Runner로 빌드하니 아래와 같이 에러가 나온다.
[
"SLF4J: Class path contains multiple SLF4J providers.",
"SLF4J: Found provider [org.slf4j.simple.SimpleServiceProvider@685f4c2e]",
"SLF4J: Found provider [ch.qos.logback.classic.spi.LogbackServiceProvider@7daf6ecc]",
"SLF4J: See https://www.slf4j.org/codes.html#multiple_bindings for an explanation.",
"SLF4J: Actual provider is of type [org.slf4j.simple.SimpleServiceProvider@685f4c2e]",
"Exception in thread \"main\" java.lang.reflect.InvocationTargetException",
"\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)",
"\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)",
"\tat java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)",
"\tat java.base/java.lang.reflect.Method.invoke(Method.java:568)",
"\tat org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)",
"\tat org.springframework.boot.loader.Launcher.launch(Launcher.java:95)",
"\tat org.springframework.boot.loader.Launcher.launch(Launcher.java:58)",
"\tat org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)",
"Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.simple.SimpleLoggerFactory loaded from jar:file:/payment-api.jar!/BOOT-INF/lib/slf4j-simple-2.0.7.jar!/). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.simple.SimpleLoggerFactory",
"\tat org.springframework.util.Assert.instanceCheckFailed(Assert.java:713)",
"\tat org.springframework.util.Assert.isInstanceOf(Assert.java:632)",
"\tat org.springframework.boot.logging.logback.LogbackLoggingSystem.getLoggerContext(LogbackLoggingSystem.java:381)",
"\tat org.springframework.boot.logging.logback.LogbackLoggingSystem.beforeInitialize(LogbackLoggingSystem.java:122)",
"\tat org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationStartingEvent(LoggingApplicationListener.java:238)",
"\tat org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:220)",
"\tat org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172)",
"\tat org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)",
"\tat org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)",
"\tat org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)",
"\tat org.springframework.boot.context.event.EventPublishingRunListener.multicastInitialEvent(EventPublishingRunListener.java:136)",
"\tat org.springframework.boot.context.event.EventPublishingRunListener.starting(EventPublishingRunListener.java:75)",
"\tat org.springframework.boot.SpringApplicationRunListeners.lambda$starting$0(SpringApplicationRunListeners.java:54)",
"\tat java.base/java.lang.Iterable.forEach(Iterable.java:75)",
"\tat org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:118)",
"\tat org.springframework.boot.SpringApplicationRunListeners.starting(SpringApplicationRunListeners.java:54)",
"\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:303)",
"\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1305)",
"\tat org.springframework.boot.SpringApplication.run(SpringApplication.java:1294)",
"\tat kr.janeshop.payment.PaymentApplicationKt.main(PaymentApplication.kt:15)",
"\t... 8 more"
]
찾아보니 logback에서 이미 라이브러리를 선언하고 있어서 라이브러리가 중복되어 발생한 에러다.
gradle.build 파일에서 slf4j 라이브러리를 제외하도록 설정해주면 된다.
configurations {
all {
exclude(group = "org.springframework.boot", module = "spring-boot-starter-logging")
exclude(group = "ch.qos.logback", module = "logback-classic")
exclude(group = "org.slf4j", module = "slf4j-log4j12")
}
}
반응형