Hibernate初始化时的Could not parse configuration
来源:互联网 发布:农产品网络推广方案 编辑:程序博客网 时间:2024/06/05 11:17
Hibernate could not parse configuration is shown when you are running program or running the Hibernate Configurations after you have configurated the cfg.xml!
Don't worry! It is a configuration error, even though it is a drawback that DOCTYPE cites a wrong URL of Hibernate configuration file(cfg.xm) ,that is time, you can use
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd" to instead the "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd" original, or each other is insteaded. How surprise it is!
____________________________________________________________________________________________________________________________________
Cite: http://blog.csdn.net/mydeman/article/details/6134820
今天一个同事需要在项目中使用Hibernate,于是就推荐了他去阅读Hibernate的官方文档。因为这个文档不但有中文,而且还包含了一个比较详细的Tutorial。
可是当一切都配置以后,使用JUnit测试时,出现了问题:
很是奇怪,因为hibernage.cfg.xml配置文件是从Tutorial中直接copy过来的,只是改了数据库的驱动、方言和连接。也Google了一些情况出来,很多是由于DTD的版本和配置文件的版本不对导致的。不过在我们这里不存在这个情况。不过可以判定是由于DTD引起的问题,忽然想起来前一段时间服务器上一个程序由于不能连接网络,而导致Springframework不能加载的问题,就判断也可能是因为网络的问题,不能下载“http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd”(尽管我们已经把DTD下载到了本地)。
这时候还好有一段以前可以运行的程序,拿来一看恍然大悟,还果真是DTD的问题。那个配置文件里引用的是:“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”,不是一个地址。替换后,问题就解决了。
官方文档也害人呀!
总结:
问题现象:加载Hibernate时出现异常,可以看到异常信息:
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect
原因:hibernate.cfg.xml中引用了错误的DTD文件路径“http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd”。
解决方法:替换为正确的DTD路径:“http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd”。
- Hibernate初始化时的Could not parse configuration
- Hibernate初始化时的Could not parse configuration
- Hibernate初始化时的Could not parse configuration
- Hibernate初始化时的Could not parse configuration
- Could not parse configuration: /hibernate.cfg.xml的解决方案
- Could not parse configuration: /hibernate.cfg.xml
- Could not parse configuration /hibernate.cfg.xml
- Could not parse configuration: /hibernate.cfg.xml
- Could not parse configuration: /hibernate.cfg.xml
- Hibernate 使用时出现 Could not parse configuration: /hibernate.cfg.xml 的异常问题
- org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
- Struts整合Hibernate:Could not parse configuration: /hibernate.cfg.xml
- org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml的问题
- 使用hibernate出现could not parse configuration:hibernate.cfg.xml 错误的解决办法
- Could not parse configuration: /hibernate.cfg.xml 异常
- org.hibernate.HibernateException: Could not parse configuration: file
- [Classpath]: Could not parse configuration: ……\hibernate.cfg.xml
- Could not parse configuration: /hibernate.cfg.xml 问题
- java长字符串变短串工具类
- MYSQL数据库调优教程
- 嵌入式环境搭建之虚拟机软件环境
- RFID系统信号的通信过程
- 排序算法性能及选择总结
- Hibernate初始化时的Could not parse configuration
- Building 'MyApplication' Gradle project info 的解决办法 android studio V8.0版本
- 数字三角形问题 NOJ 1226
- java设计模式基础-单例模式的几种写法
- 计算机组成第五周:单周期处理器
- [LeetCode][Database]Nth Hightest Salary
- fgbfdcbfbvcbcvbvcbcvbvc
- String和Date之间的转换。。
- Rainy season best wbp brown film faced plywood