问题描述
报错
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.coldwind.easyojbackendquestionservice.service.QuestionService.getBaseMapper
解决思路
-
debug 我的项目,再执行 QuestionController 这个 Question question = questionService.getById(id); 方法时直接报错了
-
上网查这个报错的解决方法,找到了解决方案 https://blog.csdn.net/weixin_44106947/article/details/122910406
解决方法
在启动主类的 @MapperScan("com.xxx.xxx.mapper")
注解加上这个 mapper,我之前是 @MapperScan("com.xxx.xxx")
,导致 mybatis 没有扫到我的 mapper 包
总结
以后遇到这种 mybatis 的 binding 错误就要想到这个问题了
纯纯是我自己犯病了,单体项目的这里是加了 mapper 的,可能是复制包名的时候漏写了!