Website content quality is poor, distribution efficiency is too low how to do?Huawei engineers offer 5 unique skills>>>
Logback has been used to replace log4j in the project, but an error is still reported when generating the release version:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.apache.log4j.Log4jLoggerFactory
According to the table, the class like log4j can’t be found all the time. Later, the jar that this class relies on can’t be found. Baidu basically determined that the main reason is not the lack of jar package, but the jar conflict. However, log4j has not been referenced in the project for a long time. And I can’t convert all the loggers that reference log4j into logback loggers
Solution
= = = = = = = = = = =
through MVN D ependency:tree After execution, it is found that the jar of back SSO client referenced by background project is log 4J dependent. Find all jars that depend on log4j, and force to exclude dependency on jars in
POM
& lt; exclusions>
< exclusion>
< groupId> org.slf4j</ groupId>
< artifactId> slf4j-log4j12</ artifactId>
</ exclusion>
< exclusion>
< groupId> log4j</ groupId>
< artifactId> log4j</ artifactId>
</ exclusion>
</ exclusions>
======
if log4j-over-slf4j.jar and slf4j-log4j12.jar coexist, the startup of loggerfactory will fail
Similar Posts:
- SLF4J: Detected both log4j-over-slf4j.jar AND bound slf4j-log4j12.jar on the class path
- Factory method ‘eurekaClient’ threw exception; nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient!
- [Exception] LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either r…
- ERROR in ch.qos.logback.core.joran.spi.Interpreter@73:41 – no applicable action for [AppenderRef], current ElementPath is [[Configuration][Loggers][Root][AppenderRef]]
- [Solved] java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUni
- Springcloud: gateway module startup error
- [Solved] Logback configuration error: SLF4J: Class path contains multiple SLF4J bindings.
- Could not transfer artifact org.glassfish:javax.el:pom:3.0.1-b06-SNAPSHOT from/to jvnet-nexus-snapshots (https://maven.java.net/content/repositories/snapshots)
- [Solved] SpringBoot Access Redis Error: java.lang.NoSuchMethodError: redis.clients.jedis.JedisPoolConfig.setMinEvictableIdleTime
- Springboot is compatible with jackson.databind and reports errors [How to Solve]