[英]Can not running application with Spring Framework
I have defined a simple class that looking like this 我已经定义了一个看起来像这样的简单类
public class Spring1 {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");
}
}
And my configuration file is 我的配置文件是
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
When i run the application it shows the following errors 当我运行该应用程序时,它显示以下错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:164)
at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:89)
at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:58)
at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:61)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at project.on.spring.Spring1.main(Spring1.java:10)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory
at java.net.URLClassLoader$1.run(Unknown Source)
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)
... 7 more
Please help me where i have made mistake. 我帮我弄错了。
Donwload commons-logging and place the jar(s) in WEB-INF/lib.Spring framework come with a lot of libraries. Donwload commons-logging并将jar放在WEB-INF / lib.Spring框架中,附带了很多库。 Make sure you have added all the required ones in your class path.
确保在类路径中添加了所有必需的内容。
And for the future - google the class name that is not found to see which library it belongs to, download it and put it on the classpath. 而对于未来 - 谷歌找不到的类名称,看看它属于哪个库,下载并将其放在类路径上。
org.apache.commons.logging.LogFactory
is not compatible with your Spring version. org.apache.commons.logging.LogFactory
与您的Spring版本不兼容。
Download the JAR
下载
JAR
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.