0

今日、私は Hibernate を発見しています。最小限のプログラムで "hibernate.cfg.xml" 構成ファイルを見つけようとして苦労しています。

これが私がすでに試したことです:

私のメイン:

package testHibernate;

import org.hibernate.cfg.Configuration;

public class Main
{
    public static void main(String[] args)
    {
        Configuration configuration = new Configuration().configure();
    }
}

このメイン ファイルの同じレベルで:

hibernate.cfg.xml

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration SYSTEM
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
   <session-factory>
       <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
       <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
       <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/pianissimo</property>
       <property name="hibernate.connection.username">admin</property>
       <property name="hibernate.connection.password">nx5fDdVdEGVDS6Tq</property>
    </session-factory>
</hibernate-configuration>

どんな助けでも大歓迎です:) 心から、アラン

4

1 に答える 1

0

hibernate.cfg.xmlクラスと同じレベルに置くべきではありませんMaintestHibernateソースフォルダーのルートで、パッケージと同じレベルに配置する必要があります。hibernate.cfg.xmlまたは、このようにパスを指定する必要があります

Configuration configuration = 
    new Configuration().configure("/testHibernate/hibernate.cfg.xml");
于 2016-01-11T15:49:20.863 に答える