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

改成

mybatis-plus:

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

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值