mybatisPlus出现There is no getter for property named ‘id‘ in ‘class com.baomidou.mybatisplus解决方法

前言

使用 mybatis-plus 时出现 org.springblade.core.tenant.exception.TenantDataSourceException: nested exception is org.apache.ibatis.reflection.ReflectionException:
There is no getter for property named ‘id’ in ‘class com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper’
的一次报错。

一.问题截图

截图如下:

在这里插入图片描述

二.问题原因&解决方法

这个报错咋一看,还以为是 id 没有 get、set 方法,但我去看实体类代码是有的,所以我就去我使用 mybatis-plus 的地方,发现 selectById(Serializable id) 方法用错了,这个方法是传id即可,但是我传了一个 mybatis-plus 条件构造器,这个返回是单个对象,而我是要条件查询返回多条数据,所以改成 selectList(Wrapper queryWrapper) 即可。
当然还有可能其他使用错误也会报以上这个错误,这里记录一下。
在这里插入图片描述

我项目引用的mybatis-plus 框架源码

在这里插入图片描述

三.getById(Serializable id) 同上问题( 可忽略 )


参考文章:https://blog.csdn.net/weixin_43726137/article/details/123094489

猜你喜欢

转载自blog.csdn.net/y2020520/article/details/131931007