

org.apache.ibatis.binding.BindingException错误的原因以下几种
1.mapper接口(GoodsMapper.java)是否与mapper.xml(GoodsMapper)是否在同一个包下
SpringBoot项目,所以说,是肯定不在一起的,只需要在mapper.xml中引入mapper接口的即可,如下:
mapper namespace="com.wonderment.assembly.mapper.GoodsMapper
2.mapper namespace引入的名称是否与mappe接口相同
直接把名字复制了一遍
<mapper namespace="com.wonderment.assembly.mapper.GoodsMapper"></mapper>
3.mapper接口中的方法名()不一致
void insertGoods(Goods goods);方法名是insertGoods)需要与mapper.xml中的一条sql的id<insert id="insertGoods"></insert>一致
4.如果mapper接口中的方法的返回值是List集合,那么在mapper.xml里面需要配置resultMap="实体的包名与类名",不要用resultType
5.delete sql语句,是不需要返回值,我写了返回实体对象,修改一下mapper接口中方法的返回值为void即可
————————————————
本文详细介绍了ApacheMyBatis中BindingException的五种常见原因,包括mapper接口与XML文件的命名空间匹配、方法名对应、返回值类型以及SQL语句配置。特别关注了SpringBoot项目中的注意事项。

3万+

被折叠的 条评论
为什么被折叠?



