0

运行 Tomcat 时出现此错误:

原因:org.springframework.beans.factory.BeanCreationException:
在类路径资源[beans.xml]中定义名称为“sessionFactory”的bean创建错误:调用init方法失败;嵌套异常是
org.hibernate.MappingNotFoundException:资源:
com/itheima/elec/domain/ElecText.hbm.xml 未找到

但它确实存在于我的项目中:

在我的 Hibernate 配置中,如下所示:

<session-factory>
    ...
    <mapping resource="com/itheima/elec/domain/ElecText.hbm.xml"/>
    <mapping resource="com/itheima/elec/domain/ElecCommonMsg.hbm.xml"/>
</session-factory>

不知道问题出在哪里,有朋友能帮帮我吗?

4

1 回答 1

0

请为您的域文件夹中的类使用@Annotations,然后您无需使用 hbm.xml 文件。之后在 hibernate.cfg.xml 文件中使用 ''

于 2017-04-12T12:02:39.217 回答