最近寫項目使用hibernate默認的dtd,在啟動項目時經常會出現這個問題,hibernate報錯,配置factory的id找不到,找不到mapping配置文件,
不能讀取配置的xml文件
Could not parse mapping document from input stream
...............
Caused by: org.hibernate.InvalidMappingException: Could not parse mapping document from input stream
..............
Caused by: org.dom4j.DocumentException: www.hibernate.org Nested exception: www.hibernate.org
..............
查了很多資料,終於找到一個有效的解決辦法:
在POJO類對應的xxx.hbm.xml配置文件中,將"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">改為:
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd",重新啟動項目,即可解決問題。