Hibernate报如上异常: org.hibernate.MappingException: Unknown entity: 解决

Hibernate报如下错误: org.hibernate.MappingException: Unknown entity: 解决
控制台报错:

Caused by: org.hibernate.MappingException: Unknown entity: com.SpringMvcTest.model.Questions
at org.hibernate.impl.SessionFactoryImpl.getEntityPersister(SessionFactoryImpl.java:550)
at org.hibernate.impl.SessionImpl.getEntityPersister(SessionImpl.java:1338)


分析:

      这个异常的意思就是某个类没有被映射。

这里是  com.SpringMvcTest.model.Questions类

解决方法:

       需要把类的映射文件加载到hibernate.cfg.xml (如果是spring mvc 看看加載的.cfg.xml 方式有么有錯)
我的原先是:
<property name="mappingDirectoryLocations">
<list>
<!--  <value>classpath:/config/hibernate</value>  Mysql -->
  <value>classpath:/config/hibernate/a</value> <!--Ms sql -->
</list>
</property>