您的位置:首页 > 运维架构

MyBatis报错:There is no getter for property named 'class_id' in 'class XXX

2019-02-21 23:02 351 查看

今天在持久层查询数据库时遇到一个错误:There is no getter for property named 'class_id' in 'class XXX

[code]
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名称是否匹配!!!

这四个地方的定义是否一致。

吃一堑长一智,写代码一定要看仔细。。。

 

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐