Mybatis java.lang.IllegalArgumentException: Result Maps collection does not contain value for com

 1.java.lang.IllegalArgumentException: Result Maps collection does not contain value for com.model.User    

解決:一、

當mapper XML文件中存在 <resultMap id="BaseResultMap" type="com.lanstech.platform.model.User">

應該在<select>標籤中的屬性改爲resultMap ="BaseResultMap"

解決:二、

將resultMap 改爲resultType =“com.lanstech.platform.model.User”

這樣會出現一些問題:類似於返回的許多數據是null。

這是由於返回值匹配的是com.lanstech.platform.model.User而對於返回的屬性都是數據庫的字段名,當數據庫的字段名和User中的屬性名不同時是不能匹配數據的。

所以用這個方法的時候需要數據和屬性名相同。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章