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