报错信息:
Context initialization failed
Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/config/application-context.xml]: Invocation of init method failed;
nested exception is org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
错误原因:配置文件出错。
使用Hibernate Tools 4.3.1.Final自动生成的*.hbm.xml文件中,文档类型(DOCTYPE )有问题
解决方案:
文档类型由
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
改为
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">