xxx.hbm.xml not found but it actually exists

1.9k Views Asked by At

I get this error when I run Tomcat:

Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'sessionFactory' defined in class path resource [beans.xml]: Invocation of init method failed; nested exception is
org.hibernate.MappingNotFoundException: resource:
com/itheima/elec/domain/ElecText.hbm.xml not found

But it is really exists in my project:

And in my Hibernate configuration is like below:

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

I don't know where the issue is, can some friend help me?

1

There are 1 best solutions below

1
NaveeN On

Please use @Annotations for the classes inside your domain folder,then you no need to use hbm.xml files. After that in hibernate.cfg.xml file use ''