"Exception in thread "main" org.hibernate.HibernateException: 无法解析配置: hibernate.cfg.xml"
"Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml"
这里是新手!!!我对 HIBERNATE 编程有疑问,我遇到了这个错误,即使做了这么多研究我也无法解决!当我第一次执行程序时,它被成功处理并且值被插入数据库,但突然间我收到了这个错误,从那以后就无法继续前进了!
PS:当我尝试 运行 我朋友电脑上的同一个程序时,它有效:/
以下是 CONSOLE 中的错误:
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 个 c
下面是我的 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">
这里是新手!!!我对 HIBERNATE 编程有疑问,我遇到了这个错误,即使做了这么多研究我也无法解决!当我第一次执行程序时,它被成功处理并且值被插入数据库,但突然间我收到了这个错误,从那以后就无法继续前进了! PS:当我尝试 运行 我朋友电脑上的同一个程序时,它有效:/
以下是 CONSOLE 中的错误:
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 个 c
下面是我的 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">