mybatis-plus 项目Invalid bound statement (not found)

我的工程目录如下
在这里插入图片描述
启动类mapper接口扫描

@SpringBootApplication
@MapperScan("com.eoffice.mapper") //mapper interface scanner
public class EofficeApplication {
	
	public static void main(String[] args) {
		SpringApplication.run(EofficeApplication.class, args);
	}
}

yml配置mapper-location

#yml文件配置mapper xml路径

mybatis:  
 mapper-locations: classpath:mybatis/mapper/*.xml 

搜寻网上其他博客,得到排查错误的几个要点

  1. 比较mapper.xml 里面的 namespace与mapper接口实际类路径是否一致
  2. 比较mapper接口的方法名称和mapper.xml里面的标签id的值是否一致
  3. 构建失败,查看target文件夹下面是否存在mapper xml 文件,没有请重新构建 在这里插入图片描述
    经过检查,我发现前面三点,项目中都没有出错。
    最后想到了mapperscan以及yml中的location可能会出错。 同时排除掉mapperscan,因为如果mapperscan出错,那么项目启动的时候就会报bean找不到的错误(service层依赖于mapper接口)例如下面
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {

	@Autowired
	private AdminMapper adminMapper;
	
	//...省略掉其他业务代码
	}

于是排查yml中的location, 在yml中输入mybatis.mapper-locations后,编译器会提示有两个选择,一个是mybatis,另一个是mybatis-plus。
考虑到项目使用了mybatis-plus,于是选择mybatis-plus.mapper-locations后,重启项目后,错误得到了解决。
在这里插入图片描述
更改后yml配置如下

#config mybatis plus log impl (show sql), and mapper-locations
mybatis-plus:
  configuration:
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  mapper-locations: classpath:mybatis/mapper/*.xml
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值