IllegalArgumentException,Mapped Statements collection does not contain value for xxxxx
不合法参数异常IllegalArgumentException,Mapped Statements collection does not contain value for xxxxx
一、报错
第一个报错:
Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.dao.ClazzMapper.selectByPrimary
第二个报错:
###Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.dao.ScoresMapper.selectBystuid
###The error may exist in com/dao/StudentMapper.java (best guess)
###The error may involve com.dao.StudentMapper.selectByPrimaryKey
###The error occurred while handling results
###SQL: select * from student where id = ?
###Cause: java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for com.dao.ScoresMapper.selectBystuid
这两个错误都报的是 不合法的参数异常
。映射语句中不包含xxx
二、分析
第一个错误说:映射语句集合不包含com.dao.ClazzMapper.selectByPrimary 的值。说明这个方法不在映射集合里面。仔细检查一下是不是方法名写错了。
第二个错误说:映射语句集合里不包含 com.dao.ScoresMapper.selectBystuid 这个值,而且指明错误是在执行这条语句时产生的 The error occurred while handling results ###SQL: select * from student where id = ?
,然后自己仔细的对应了一下参数是否和实体类里的属性以及数据库里的字段相互对应,结果是因为数据库的字段写错了。
三、解决办法
目前自己先总结这两个错误,等之后遇到其他的再补充吧!
- 首先要检查一下方法名,看是不是方法获取错了,有没有这个方法
- 检查一下参数,将参数和数据库的字段以及实体类里的属性对应一下,看是不是写错了
更多推荐
所有评论(0)