获取java.lang.ClassNotFoundException:org.apache

我正在执行spring的简单Dependency Injection程序并获取此异常。我已经包含了common-logging1.1.1.jar和spring.jar文件。你能帮忙吗?


Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory

    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:119)

    at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:55)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:77)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:65)

    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:56)

    at com.client.StoryReader.main(StoryReader.java:15)

Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory

    at java.net.URLClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    ... 6 more



偶然的你
浏览 252回答 3
3回答

月关宝盒

如果您正在使用maven来管理依赖项,请在pom.xml中添加以下行:<dependency>&nbsp; &nbsp; &nbsp; &nbsp; <groupId>commons-logging</groupId>&nbsp; &nbsp; &nbsp; &nbsp; <artifactId>commons-logging</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; <version>1.1.1</version></dependency>

哔哔one

commons-logging-1.1.1.jar或jcl-over-slf4j-1.7.6.jar al如果使用的是maven,请使用以下代码。<dependency>&nbsp; &nbsp; <groupId>org.slf4j</groupId>&nbsp; &nbsp; <artifactId>jcl-over-slf4j</artifactId>&nbsp; &nbsp; <version>${slf4j.version}</version></dependency>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java