您的位置:首页 > 运维架构 > Tomcat

使用Hibernate过程中出现entity class not found 问题的解决思路

2017-07-31 20:44 411 查看
启动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配置文件中

上述方法仅是我个人总结的方法
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  tomcat hibernate entity
相关文章推荐