mybatis出现There is no getter for property named ‘Id‘ in ‘class com.baomidou.mybatisplus
记录一下我在工作中,使用 mybatis-plus 时出现 There is no getter for property named ‘id’ in ‘class com.baomidou.mybatisplus.core.conditions.query.QueryWrapper’ 的一次报错org.mybatis.spring.MyBatisSystemException: nested e
记录一下我在工作中,使用 mybatis-plus 时出现 There is no getter for property named ‘id’ in ‘class com.baomidou.mybatisplus.core.conditions.query.QueryWrapper’ 的一次报错
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class com.baomidou.mybatisplus.core.conditions.query.QueryWrapper'

这个报错咋一看,还以为是 id 没有 get、set 方法,但我去看实体类代码是有的,所以我就去我使用 mybatis-plus 的地方,发现 getById(Serializable id) 方法用错了,这个方法是传id即可,但是我传了一个 mybatis-plus 条件构造器,这个返回是单个对象,而我是要条件查询返回多条数据,所以改成 list(Wrapper queryWrapper) 即可。
当然还有可能其他使用错误也会报以上这个错误,这里记录一下。
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)