ClassNotFoundException: org.apache.commons.logging.LogFactory
Запуск веб-приложения, но появляется следующее сообщение об ошибке:
... Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory ...
1. Нормальный случай
1.1 Obviously, the Apache Commons logging is missing – commons-logging-xxx.jar
. Чтобы исправить это, получите его из центрального хранилища Maven.
pom.xml
commons-logging commons-logging 1.2
2. Весенний случай
2.1 For Spring application, developers always excluded the commons-logging
, but forget to include another logging framework. Например
pom.xml
org.springframework spring-webmvc ${spring.version} commons-logging commons-logging
Вышеупомянутое объявление также вызовет этотclassNotFoundException: org.apache.commons.logging.LogFactory
.
2.2 To fix it, declares another logging framework, often, this is SLF4j and redirect the Spring’s logging via a bridge.
pom.xml
org.springframework spring-webmvc ${spring.version} commons-logging commons-logging org.slf4j jcl-over-slf4j ${jcl.slf4j.version} ch.qos.logback logback-classic ${logback.version}