43.bug:mapper接口参数使用@param重命名导致的错误
错误信息:Nested exception is org.apache.ibatis.binding.bindingException:parameter inVo not found
public interface UserMapper{
//查询用户列表
User queryUserList(@Param ("inVo") UserInVo userInVo);
}
对应的UserMapper如下:
selelct id,name,age,phone,createtime from tb_user A
A.name=#{inVo.name}
A.age=#{userInVo.age}
order by A.createtime desc
原因 :mappper 的接口方法中,因为使用@Param注解,重命名入参,但是SQL中没有使用重命名的参数名导致
改正:SQL使用重命名后的参数名
selelct id,name,age,phone,createtime from tb_user A
A.name=#{inVo.name}
//错误改正:userInVo改正为:inVo
A.age=#{inVo.age}
order by A.createtime desc