建议在使用Mybatis时,一定要加上@param注解
踩了一个坑,报错为:
aused by: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'flowId' not found. Available parameters are [arg1, arg0, param1, param2] at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:77) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446)
解决方法为在使用Mybatis时,加上@Param注解,否则尽管在接口中定义了参数的名称,mybatis仍然不认识:
@Repository
public interface MMMDao extends Mapper<AAA> {
List<AAA> selectByFlowRuleId(@Param(value="flowId") Long flowId, @Param(value="ruleId") Long ruleId);
}