【发布时间】:2013-04-28 20:09:19
【问题描述】:
我已关注this 教程。
这是我的文件夹结构:
当我运行 App.Java 时,我得到:
Initial SessionFactory creation failed.org.hibernate.MappingNotFoundException: resource: com/mkyong/user/DBUser.hbm.xml not found
但是,如您所见,我有那个文件。当我把文件放在
src/main/java/com/mykong/user/DBUser.hbm.xml
我仍然收到此错误。
我怎样才能使这个例子工作?
谢谢。
编辑:
hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:mysql://localhost:3306/sampleapplication</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.username">root</property>
<property name="connection.password">MYPASSWORDHERE</property>
<property name="show_sql">true</property>
<mapping resource="com/mkyong/user/DBUser.hbm.xml"></mapping>
</session-factory>
</hibernate-configuration>
【问题讨论】:
-
我们可以看看你的hibernate.cfg.xml
-
@blackpanther 谢谢,我已经编辑了我的问题。