MyBatis-Plus找不到Mapper.xml文件的解决方法

在整合SpringBoot和Mybatis-plus时,想写自定义的sql,所以创建了Mapper.xml文件,但是启动后却老是报错:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

很明显,是Mapper.xml未被扫描到。

此类问题的解决方式实际上都是配置上有问题,以下列出了一些解决方式。

**方式1:**Mapper的命名空间和Dao层的接口。

Mapper.xml文件中,

**方式2:**如果Mapper.xml文件是放到java目录下,那么在项目的pom.xml文件中需要添加:

src/main/java \*\*/\*.xml

**方式3:**注意在.yml配置文件中不要弄混淆Mybatis和Mybatis-plus的配置

比如项目pom.xml中引用的是Mybatis-plus的starter,其中已经包含了Mybatis了,配置文件中最好统一写成Mybatis-plus的配置:

mybatis:

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

扫描二维码关注公众号,回复: 14306574 查看本文章

改成

mybatis-plus:

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

**方式4:**如果是多子模块的项目,Mapper.xml文件是在子模块项目中,那

猜你喜欢

转载自blog.csdn.net/m0_61083409/article/details/125155671