使用Hibernate出现nested exception is org.hibernate.MappingException: entity class not found:问题

启动tomcat 后出现如下错误:

严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext

 resource[/WEBINF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException:

 entity class not found: com.nit.ssh.entities.User


第一步:

检查一下  *.hbm.xml 文件 class 的 name 属性填写是否正确,即关联的实体类的路径




第二步:检查tomcat 是否与项目同步,及找到

 Work Space\

.metadata\

.plugins\

org.eclipse.wst.server.core\

tmp0\

wtpwebapps\

SSHProject\

WEB-INF\classes\com\nit\ssh\entities 目录下,查看是有实体类的.class 文件,如下图:



如果没有,说明没有同步,在Eclipse中clean 一下




第三步:检查下hibernate.cfg.xml中是否配置了相关的 *.hbm.xml ,如果是整合spring,可以在Spring配置文件中



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值