当前位置: 代码迷 >> J2EE >> new ClassPathXmlApplicationContext时出错误
  详细解决方案

new ClassPathXmlApplicationContext时出错误

热度:78   发布时间:2016-04-22 01:56:28.0
new ClassPathXmlApplicationContext时出异常
Java code
ApplicationContext ac=new ClassPathXmlApplicationContext("beans.xml");

是抛异常
这是异常信息:
Java code
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory    at org.springframework.context.support.AbstractApplicationContext.<init>(AbstractApplicationContext.java:145)    at org.springframework.context.support.AbstractRefreshableApplicationContext.<init>(AbstractRefreshableApplicationContext.java:84)    at org.springframework.context.support.AbstractRefreshableConfigApplicationContext.<init>(AbstractRefreshableConfigApplicationContext.java:59)    at org.springframework.context.support.AbstractXmlApplicationContext.<init>(AbstractXmlApplicationContext.java:58)    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:136)    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)    at com.springmodel.A.main(A.java:14)

这是beans.xml中的信息
Java code
<?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-2.5.xsd">    <bean id="moni" class="com.springmodel.Moni">        <property name="mi" value="测试IC" />    </bean></beans>


------解决方案--------------------
org/apache/commons/logging这个包有没有加上?
------解决方案--------------------
探讨

org/apache/commons/logging这个包有没有加上?