近來搭建ssh框架遇到了以下問題
org.springframework.orm.hibernate4.HibernateSystemException: Unknown entity: com.ssh.csr.model.User; nested exception is org.hibernate.MappingException: Unknown entity: com.ssh.csr.model.User
截圖如下:
這類問題是找不到實體類,就有很多種錯誤的可能性
1:有可能是User類配置字段名有問題
2:有可能是映射文件User.hbm.xml中
包名引錯了
4:jsp中input的name屬性可能出現錯誤(可能不是報這種錯,是報找不到username所以jsp的值傳不過去)
5:配置文件applicationContext.xml中
<property name="mappingLocations">
<list>
<value>classpath*:com/ssh/csr/model/*.hbm.xml</value>
</list>
</property>
包名是要用下劃線的:com/ssh/csr/model
切記不能寫成com.ssh.csr.model