hibernate的org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection

在使用Hibernate时遇到DocumentException,提示连接超时。问题根源在于解析hibernate.cfg.xml和*.hbm.xml时,DTD验证失败。解决方案是检查hibernate.jar中DTD文件的头部引用,确保与配置文件一致,正确格式应包含正确的DTD声明和来源URL。
摘要由CSDN通过智能技术生成

今天在练习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">

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值