原来是偷懒用MyEclipse自动生成Hibernate映射文件后,hibernate.cfg.xml最顶上的几行没有,从而报错误:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: invalid configuration
解决办法是把下面这段话加上:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0 //EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
Could not parse mapping document from resource User.hbm.xml
此 错误时粗心大意忘记建立数据库表了
原文地址:http://hi.baidu.com/liujun12337/item/1df0febcb34bd173254b09d4