0
点赞
收藏
分享

微信扫一扫

springboot mybati报错Invalid bound statement (not found): com.bjsxt.mapper.xxxxxx

绪风 2022-03-11 阅读 76

报错原因

检查思路

背景:
1.springboot maven 项目从eclipse导入
2.使用mapper代理开发方式

mybatis 的mapper 位置(.java .xml 的都需要检查)
maper 的名字与xml 内是否一致
方法名与id 是否一致
application的扫描是否配置正确

mybatis 的mapper.xml 位置

特别注意userMapper.xml 的位置
在myeclipse 内 main/java下的xml 可以直接访问
idea 不行,必须放到resource 下
参考配置方法
本人就是问题出在这里,没配置扫描的位置
在这里插入图片描述

mybatis 使用规范

Mapper代理开发方式(推荐)

Mapper代理的开发方式,程序员只需要编写mapper接口(相当于dao接口)即可。Mybatis会自动的为mapper接口生成动态代理实现类。
不过要实现mapper代理的开发方式,需要遵循一些开发规范。

开发规范

1、 mapper接口的全限定名要和mapper映射文件的namespace的值相同。
2、 mapper接口的方法名称要和mapper映射文件中的statement的id相同;
3、 mapper接口的方法参数只能有一个,且类型要和mapper映射文件中statement的parameterType的值保持一致。
4、 mapper接口的方法参数如输入多个时接口中必需加入注解@Param,且mapper映射文件中不需要parameterType
5、 mapper接口的返回值类型要和mapper映射文件中statement的resultType值或resultMap中的type值保持一致;

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

举报

相关推荐

0 条评论