使用Mybatis出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.just1t.fileservice.service.FileService.LoadDatePage

一般的解决方式:
1、检查xml文件名和mapper接口名字是否一致

2、检查xml文件中的namespace和mapper接口的全类名是否一致

3、检查xml文件中的方法名和mapper接口中的方法名是否一致

4、检查target中是否存在xml文件,如果不存在有两种方式,第一种是在yml文件中配置,第二种是在pom.xml文件中配置
这里使用第二种方式:

我尝试之后,都无法解决

这时我仔细观察了下,
注意到我出现的问题:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.just1t.fileservice.service.FileService.LoadDatePage

他喵的,居然是Service出现了这个问题,com.just1t.fileservice.service.FileService.LoadDatePage,什么意思,就是想直接通过Service直接调方法请求后端,
但是,我仔细看了看我的代码,不是这样的呀,我还特意打了断电判断是否经过Service层的处理,完全没有,直接就出现了这个异常。

这时候,我就挺郁闷的,我的这个项目是微服务,刚写完一个模块,我比对了半天,结构上没发现有什么不同,后想到会不会是我定义的这个类的名字有问题,改了下Service层的名字
,run,这次出现的问题不同了,Field fileService in com.just1t.fileservice.controller.FileController required a single bean, but 2 were found:
它说找到了两个bean,把这个问题在网上一收,就说在Mybatis中,@Mapper和@MapperScan使用一个就够了,因为我在@Component和@MapperScan中的basepackage一样的,所以就有了两个bean,
之后,将@MapperScan删除之后,程序就好了。

posted @ 2024-06-08 22:41  just1t  阅读(19)  评论(0编辑  收藏  举报