Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
教程don'中的Hibernate示例;行不通_Hibernate_Configuration - Fatal编程技术网

教程don'中的Hibernate示例;行不通

教程don'中的Hibernate示例;行不通,hibernate,configuration,Hibernate,Configuration,我正在学习hibernate教程。我已经创建了hibernate.cfg.xml 本教程的第一个示例不起作用。调用configure方法时,它抛出一个HibernateException报告配置无效。这里我留下了代码: 我的hibernate.cfg.xml类似于: <hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration" xsi:schemaLocation="http:/


我正在学习hibernate教程。我已经创建了hibernate.cfg.xml
本教程的第一个示例不起作用。调用configure方法时,它抛出一个HibernateException报告配置无效。这里我留下了代码:

我的hibernate.cfg.xml类似于:

<hibernate-configuration
xmlns="http://www.hibernate.org/xsd/hibernate-configuration"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<session-factory>
    <!-- Database connection settings -->
    <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.connection.username">pepe</property>
    <property name="hibernate.connection.password">pepe</property>
    <property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/hibernate</property>
    <property name="connection_pool_size">1</property>
    <property name="hbm2ddl.auto">updated</property>
    <property name="show_sql">true</property>
    <mapping resource="hibernateexample1/domain/costumer.hbm.xml"/>
</session-factory>

org.hibernate.dialogue.PostgreSqlDialogue
org.postgresql.Driver
佩佩
佩佩
jdbc:postgresql://localhost:5432/hibernate
1.
更新
真的

您可能需要在hibernate配置的正上方添加hibernate DOCTYPE,即

<?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" >


同时检查您的xml格式是否正确,查找任何未关闭的标记,等等。不要在配置文件中看到“hibernate配置”标记的关闭。

请放置您参考此示例的教程链接!!!!谢谢在这篇文章发表几分钟后,我将代码替换为用Netbeans生成的代码,然后它就可以工作了。Regards@LeandroRouraSixto很高兴它起作用了。。!!干杯如果答案有帮助的话,你可以接受。。
<?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" >