今天在持久层查询数据库时遇到一个错误:There is no getter for property named 'class_id' in 'class XXX
org.mybatis.spring.MyBatisSystemException: nested exception
is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'class_id' in 'class com.xxx.yyy.zzz'
在网上搜了一下,好多都说
1. 在mapper文件注入参数的时候添加@Param注解
2. 或者把#{xxx}修改为#{_parameter};
反正经我本人测试没啥效果,而且把#{xxx}修改为#{_parameter}之后,系统报错又提示:There is no getter for property named '_parameter' in 'class XXX。。。。。。
个人解决办法:
好好检查一下对应的
xml
文件
检查相应字段在对应
entity实体类属性名称、
xml文件中resultMap定义的property、
sql语句column名称、
数据库column名称是否匹配!!!
这四个地方的定义是否一致。
吃一堑长一智,写代码一定要看仔细。。。