Error creating bean with name 'userDAO' defined in class path resource

2018年03月20日 682点热度 0人点赞 0条评论

eclipse报错如下

Exception in thread “main” org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userDAO’ defined in class path resource

[applicationContext.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 class path resource

[applicationContext.xml]: Instantiation of bean failed; nested exceptionis org.springframework.beans.BeanInstantiationException: Could not instantiate bean class

[org.springframework.orm.hibernate3.LocalSessionFactoryBean]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError

而且*.hbm.xml文件上有错误符号

解决方法

同样的环境,同一个eclipse,同样的文件,出不了提示的原因是我的eclipse是新装的,需要缓存hbm.xml文件中的dtd声明,而原来那个地址请求不到,所以不能正常出现提示!

附:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

其中,http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd访问不到,已经更换了新的地址

http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd

修改一下,即可解决!

Matrix

保持饥渴的专注,追求最佳的品质

文章评论