Invalid bound statement (not found): 报错
搭建SpringBoot项目时配好所有文件,在service调用数据库操作出错,这种错误一般有两种原因:
- name space 配置错误
- Mapper.xml路径有问题
1.name space 配置错误
检验是否为原因一的方法:在xml文件中按住Ctrl 鼠标点击《name space:xxx.xxx.xx》观察是否能跳转到对应的mapper接口,接口类中是否添加@Mapper注解,或者主类中添加@MapperScan注解
2.Mapper.xml文件路径存放错误
不要将mapper文件夹放到src/main/java下,mapper文件夹应当放在resource目录中,且路径要和配置文件中的mybatis mapper-locations: classpath:com/mybatis/mapper/*.xml 一致:
配置文件中:
项目路径: