0

休止状態の構成で立ち往生しています。Java プロジェクトに接続したい SQL データベースがあります。これは私のプロジェクト ツリー フォルダーです。

ここに画像の説明を入力

hibernate.cfg.xml と Alumnos.hbml.xml のコードを以下に貼り付けます。

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-configuration>
  <session-factory>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://localhost/scool</property>
    <property name="connection.username">root</property>
    <property name="connection.password"></property>
    <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>
    <property name="hibernate.show_sql">true</property>    
    <mapping resource="adrsoft/scool/pojos/Alumnos.hbm.xml"/>
  </session-factory>
</hibernate-configuration>

Alumnos.hbm.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="src.adrsoft.scool.pojos.Alumnos">
        <id column="idalumno" name="idalumno" type="integer"/>
        <property name="nombre"  type="string"/>
        <property name="apellidos" type="string"/>
        <property name="dni" type="string"/>
        <property name="direccion" type="string"/>
        <property name="email" type="string"/>
        <property name="password" type="string"/>
        <property name="telefono" type="integer"/>
        <property name="centro" type="integer"/>
        <property name="curso" type="string"/>
        <property name="club" type="integer"/>
    </class>     
</hibernate-mapping>

そして、次のエラーが発生しました。

org.hibernate.MappingException: entity class not found: src.adrsoft.scool.pojos.Alumnos
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:129)
at org.hibernate.tuple.PropertyFactory.getGetter(PropertyFactory.java:390)
at org.hibernate.tuple.PropertyFactory.buildIdentifierProperty(PropertyFactory.java:75)
at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:145)
at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:507)
at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:146)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.hibernate.persister.internal.PersisterFactoryImpl.create(PersisterFactoryImpl.java:163)
at org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:135)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:385)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1769)
at adrsoft.scool.view.Alumnos.createConnection(Alumnos.java:105)
at adrsoft.scool.view.Alumnos.<init>(Alumnos.java:96)
at adrsoft.scool.view.Alumnos$1.run(Alumnos.java:80)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$400(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: src.adrsoft.scool.pojos.Alumnos
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.internal.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.mapping.PersistentClass.getMappedClass(PersistentClass.java:126)
... 30 more

問題はフォルダのパスに関するものだと思います。ドットをスラッシュで変更しようとしましたが、両方とも同じようにクラッシュします。

誰でも私を助けることができますか?

ありがとう!

4

1 に答える 1

0

クラスのパッケージ (hibernate マッピング ファイル内) が間違っています。

代わりsrc.adrsoft.scool.pojos.Alumnosadrsoft.scool.pojos.Alumnos

于 2013-06-02T19:25:29.737 に答える