在使用mybaits遇到了如下错误:
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'date' not found. Available parameters are [3, 2, 1, 0, param1, param2, param3, param4]
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:365)
at com.sun.proxy.$Proxy9.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:160)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:95)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:40)
......
Caused by: org.apache.ibatis.binding.BindingException: Parameter 'date' not found. Available parameters are [3, 2, 1, 0, param1, param2, param3, param4]
at org.apache.ibatis.binding.MapperMethod$MapperParamMap.get(MapperMethod.java:258)
at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:40)
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:123)
... 21 more
1.首先定位问题发生的具体位置,找到了一个函数中参数写法有问题,有问题的函数:
Integer addlastdaystat(Date date,Integer allcount,Integer activecount,Integer isnewcount);
2.修改问题,修改为了:
Integer addlastdaystat(@Param("date")Date date,@Param("allcount")Integer allcount,@Param("activecount")Integer activecount,@Param("isnewcount")Integer isnewcount);
总结:这是由于没有加@param("数据库表中对应的列名")导致的