这里是新手!!!我对 HIBERNATE 编程有疑问,我收到了这个错误,即使做了这么多研究后我也无法解决!当我第一次执行程序时,它已成功处理并且值已插入数据库中,但突然我收到此错误,从那以后无法继续前进! PS:当我尝试在我 friend 的计算机上运行相同的程序时,它有效:/
<小时/>以下是控制台中的错误:
Exception in thread "main" org.hibernate.Hiberna`enter code here`teException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at com.snycon.hibernateEx.EmployeeAction.main(EmployeeAction.java:13)
由以下原因引起:org.dom4j.DocumentException:来自服务器的意外文件结尾嵌套异常:来自服务器的意外文件结尾
在 org.dom4j.io.SAXReader.read(SAXReader.java:484)
在 org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 2 个以上
下面是我的 hibernate.cfg.xml 文件:
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/jdbcex</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hbm2ddl.auto">update</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
<小时/>
最佳答案
将 hibernate.cfg.xml
的架构声明更改为:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
关于java - "Exception in thread "主要 "org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43730194/