使用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配置文件中



你可能感兴趣的:(使用Hibernate出现nested exception is org.hibernate.MappingException: entity class not found:问题)