0

这里是新手!!!我的疑问是关于 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>

4

1 回答 1

1

将架构声明更改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">
于 2017-05-02T05:38:29.283 回答