org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1542) at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:1035) at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:64) at org.hibernate.cfg.Configuration.configure(Configuration.java:1476) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64) at org.hibernate.cfg.Configuration.configure(Configuration.java:1462) at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011) at hibernateTest.UserService.main(UserService.java:12) Caused by: org.dom4j.DocumentException: Connection timed out: connect Nested exception: Connection timed out: connect at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1532) ... 8 more
注意xml的dtd是否配置正确:
我原来的dtd是这样写的:
http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd
可能无法加载了,改成下面一个配置就可以了:
http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd