Parameter ‘age‘ not found. Available parameters are [arg1, arg0, param1, param2]

报错类型

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'age' not found. Available parameters are [arg1, arg0, param1, param2]

	at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92)
	at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:440)
	at com.sun.proxy.$Proxy56.selectList(Unknown Source)
	at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:223)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:122)
	at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:87)
	at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInv

错误场景

Mapper.xml 代码

 <select id="selectPageByAge" resultType="com.atguigu.mubatisplus.entity.User">
        select <include refid="Base_Column_List"/>
        from t_user
        where age > #{age}
    </select>

测试代码


    @Test
    public void testSelectPageByAge(){
        Page<User> page = new Page<>(1,10);
        //查询年龄大于25的用户
        userMapper.selectPageByAge(page, 20);

        List<User> userList = page.getRecords();
        userList.forEach(System.out::println);
    }

解决方法

将mapper.xml代码更改为:

    <select id="selectPageByAge" resultType="com.atguigu.mubatisplus.entity.User">
        select <include refid="Base_Column_List"/>
        from t_user
        where age > #{arg1}
    </select>

即最后一句: #{age} --> #{arg1}或者#{arg0}

原因

我也不知道为啥

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
根据你提供的引用内容,我可以看出你遇到了一个错误。错误信息显示"Parameter 'startTime' not found. Available parameters are [arg1, arg0, param1, param2]" 。这个错误是由于在你的代码中找不到参数"startTime"导致的。相反,可用的参数是[arg1, arg0, param1, param2]。 为了解决这个问题,你需要确保在你的代码中正确地传递和使用参数"startTime"。可能有几种原因导致这个错误,例如拼写错误、参数未被正确声明或传递等等。你可以按照以下步骤来解决这个问题: 1. 首先,确认你的参数名字是否正确拼写。检查一下你在代码中使用参数"startTime"的地方,确保参数名字的大小写和拼写与声明时一致。 2. 确认参数是否被正确声明。在你的代码中,检查一下参数"startTime"是否在方法的参数列表中被正确声明。确保参数的类型和名称与方法的定义一致。 3. 确认参数是否被正确传递。如果你是在调用方法时遇到了这个错误,确保你在方法调用中正确传递了参数"startTime"。检查一下方法调用的参数列表,确保参数的顺序和类型与方法定义一致。 如果你仍然无法解决这个问题,可能需要进一步检查你的代码。你可以通过打印调试信息、查看日志文件或者调试器来定位问题所在。另外,你还可以参考引用和引用中关于查询和修改方法的使用方式,以确保你正确地使用和传递参数。 总结起来,当遇到"Parameter 'startTime' not found. Available parameters are [arg1, arg0, param1, param2]"这个错误时,你需要检查参数的拼写、声明和传递,确保它们与方法的定义和使用一致。如果问题仍然存在,可以使用调试工具来定位问题所在。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值