org.apache.ibatis.binding.BindingException: Parameter ‘XXXX‘ not found.的问题解决办法

问题分析

是当Dao层的方法有多个参数的时候,我们需要加入@Param注解

我下面都是用注解开发的,不是xml

例如:

[1]两个普通参数

都加上@Param注解

@Select("select * from student where id=#{id} and name=#{name})
int selectBySelective(@Param("id")int id,@Param("name")String name);

[2]既有参数又有对象

普通参数直接写,对象要写对象.属性

  @Select("select * from oilMonth where wellId=#{oilDaily.wellInfo.wellId} and time=#{previousMonth}")
    OilMonth findPreviousMonth(@Param("oilDaily") OilDaily oilDaily,@Param("previousMonth") String previousMonth);
posted @ 2021-02-27 21:05  别团等shy哥发育  阅读(116)  评论(0)    收藏  举报