Mybatis-plus报错:org.apache.ibatis.binding.BindingException:Invalid bound statement (not found)

项目场景:

项目在整合mybatis-plus的时候发现总是报错,mybatis的xml文件中的sql使用正常,而mybatis-plus的接口持续报错


问题描述

postman测试使用mybatis-plus的接口总是报错,报错信息如下:

org.apache.ibatis.binding.BindingException:Invalid bound statement (not found): com.demo.mapper.ArticleMapper.selectList

代码片段如下:

@GetMapping("/getAll")
    public Result<List<Article>> getAllArticles() {
        List<Article> articleList = articleService.list();
        return Result.success(articleList);
    }

刚遇到这个问题我第一眼就看见了selectList(),但是整个项目中都没有使用过selectList(),后来在网上找了一大堆相关的解决方案都不生效


原因分析:

  1. 这种报错常见的原因就是targetmapper文件夹中xml文件不在,但是检查了一遍没问题
  2. 试过更换mybatis-plus的版本,但是仍然不能起作用,没想过再去更换mybatis的版本
  3. controller,service,mapper,pojo每一个相关的类上检查格式都正确
  4. application.yml,还有各个配置类中 检查没有影响mybatis-plus生效的配置项

一筹莫展后,试了一下更换mybatis项目的依赖
之前:

    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>

之后:

    <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>3.0.0</version>
    </dependency>

运行项目,问题解决

发现了原因:mybatis-plus与mybatis的版本不兼容的问题
现在mybatis-plus的依赖如下:

<dependency>
      <groupId>com.baomidou</groupId>
      <artifactId>mybatis-plus-boot-starter</artifactId>
      <version>3.5.3</version>
 </dependency>

解决方案:

参考文章:
解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):xxx问题

如果无法解决,可再检查mybatis-plus和mybatis的兼容性

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

骑着猪看大海

你的鼓励是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值