最近遇到个问题,使用SpringBoot+Mybatis的时候,调用接口报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)。
仔细检查了下,原来在mybatis的xml文件中,把resultMap 和rusultType 弄错了。也是对mybatis理解不够深入,被自己蠢到了。。。。下面贴下报错信息及错误原因。
报错信息如下:
错误来源:如果自己定义了resultMap,使用的时候一定得看仔细了,别用成了resultType。
最后贴下resultMap和resultType的区别:
mybatis中在查询进行select映射的时候,返回类型可以用resultType,也可以用resultMap。resultType是直接表示返回类型的,而resultMap则是对外部ResultMap的引用,但是resultType跟resultMap不能同时存在。