Springboot-001-解决nested exception is org.apache.ibatis.binding.BindingException: Parameter 'env' not found. Available parameters are [arg1, arg0, param1, param2]

环境:Springboot + Mybatis + MySQL + VUE

场景:

前端发出数据比对请求,在服务后台与数据库交互时,接口提示错误信息如下所示:

{
"code": 999,
"success": false,
"msg": "nested exception is org.apache.ibatis.binding.BindingException: Parameter 'env' not found. Available parameters are [arg1, arg0, param1, param2]",
"menu": "DATABASE",
"action": "DATABASE_COMPARE",
"operator": "ANON",
"datetime": "2018-10-23 11:26:17.877"
}

控制台日志响应如下所示:

Springboot-001-解决nested exception is org.apache.ibatis.binding.BindingException: Parameter 'env' not found. Available parameters are [arg1, arg0, param1, param2]

解决:

由错误信息可知,Mybatis在操作数据库前未接收到请求参数,实际为Respository/Mapper中的SQL语句中引用的参数未获取到所导致的报错信息。查看源码可知,如下代码中蓝色加粗部分缺失导致的,添加后,问题解决。

    @Select("select * from `data` " +
"where eng = #{eng} and env like '%${env}%' ")
@Results({
@Result(property = "id", column = "id"),
@Result(property = "env", column = "env"),
@Result(property = "eng", column = "eng"),
})
List<Database> findAllComp(@Param("eng") String eng, @Param("env") String env);
上一篇:转:Android模拟器连接电脑网络


下一篇:[POI2018]Pionek