43.bug:mapper接口参数使用@param重命名导致的错误

作者 : admin 本文共498个字,预计阅读时间需要2分钟 发布时间: 2024-06-10 共2人阅读

错误信息: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

本站无任何商业行为
个人在线分享 » 43.bug:mapper接口参数使用@param重命名导致的错误
E-->