今天在练习hibernate时 出现了无法解析hibernate配置文件的情况 看了一下错误日志 原因是org.dom4j.DocumentException: Connection timed out
一堆错误日志就不贴出来了 大概就是 Could not parse hibernate.cfg.xml ... cause org.dom4j.DocumentException: Connection timed out
上网查看了很多资料 发现是在验证DTD地址的时候出的问题
打开工程中的hibernate.jar 里的 hibernate-configuration-3.0.dtd 和 hibernate-mapping-3.0.dtd
对应一下其中的头文件 看一下是否吻合
经验证 正确的格式是:
hibernate.cfg.xml:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
*.hbm.xml:
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">