读取spring配置文件问题!各位大大帮忙下哈
sessionFactory:在applicationContext-pub.xml文件
userDao:在applicationContext-user.xml文件
<bean id="userDao" class="userModel.dao.impl.UserDAOImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
源码:
public void testLogin(){
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext-*.xml");(抛异常!!!)
UserDAO userdao =(UserDAO)ac.getBean("userDao");
UserInfo userinfo =userdao.loginUser("xigen", "123456");
System.out.println(userinfo.getUserName());
}
报错信息:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao' defined in file [E:\workspace\MyOffic\WebRoot\WEB-INF\classes\applicationContext-user.xml]: Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\workspace\MyOffic\WebRoot\WEB-INF\classes\applicationContext-pub.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in file [E:\workspace\MyOffic\WebRoot\WEB-INF\classes\applicationContext-pub.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/dom4j/DocumentException
Caused by: java.lang.NoClassDefFoundError: org/dom4j/DocumentException