Failed to instantiate SLF4J LoggerFactory on Spring 'mvc-basic' tutorial

♀尐吖头ヾ 提交于 2019-12-06 10:46:33

Try to clean the project and server in eclipse. It looks like a refreshing problem.

If you use Maven (M2E) in Eclipse then it is correct that the libs are only in the "Maven Dependencies Section".

May you start with an Spring Source Tool Suite Template Project (that is maven based) and then you copy the code from the tutorial into this project.

If you use Tomcat, then Eclipse must copy the libs to workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp<VERSION>\wtpwebapps\<PROJECT>\WEB-INF\lib. If the lib is not there, and eclipse does not copy it even if you refersh every thing. Then sometimes the last thing you can do is, Remove the project from the server (in the "Add and Remove..." Dialog) press Finish, and then add the project again.

Looks like some other library has dependency on SLF4J. Create a WAR file and check if SLF4J.jar is packaged in the war. If not, check your Appservers common lib directory. In case its loading it. Check the Dependency graph of your pom.xml.

In case if you want to add SLF4J log4j API below is the dependency.

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.6.4</version>
</dependency>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!