java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectProvider

1.问题描述

在springboot的主启动类上使用注解@MapperScan("com.xxx.xxx")时,启动报错

java.lang.NoSuchMethodException: tk.mybatis.mapper.provider.base.BaseSelectProvider

在这里插入图片描述

2.解决思路与方案

1.查看是不是导包导错了

错误导包org.myybatis.spring.annotation.MappeerScan
在这里插入图片描述
正确导包

import tk.mybatis.spring.annotation.MapperScan;

3.拓展

org.mybatis.spring.annotation.MapperScantk.mybatis.spring.annotation.MapperScan 主要用于在 Spring 项目里扫描 MyBatis 的 Mapper 接口,不过它们来自不同的 MyBatis 相关库

  1. 所属库不同
    org.mybatis.spring.annotation.MapperScan属于 MyBatis-Spring 库,这是 MyBatis 官方的 Spring 集成库,目的是把 MyBatis 和 Spring 框架集成起来。
    tk.mybatis.spring.annotation.MapperScan属于通用 Mapper 库,该库基于 MyBatis 开发,对 MyBatis 进行了扩展,提供了通用的单表增删改查方法,降低了开发工作量。
  2. 功能差异
    org.mybatis.spring.annotation.MapperScan:仅负责扫描指定包下的 Mapper 接口,然后将这些接口注册为 Spring 的 Bean,需要手动编写 SQL 语句来实现具体的数据库操作。
    tk.mybatis.spring.annotation.MapperScan:除了具备基本的扫描功能之外,还能为实体类对应的 Mapper 接口自动注入通用的单表增删改查方法,无需手动编写这些常见的 SQL 语句
  3. 依赖配置
    要使用 org.mybatis.spring.annotation.MapperScan,需要添加 MyBatis-Spring 的依赖:
<dependency>
    <groupId>org.mybatis.spring.boot</groupId>
    <artifactId>mybatis-spring-boot-starter</artifactId>
    <version>2.3.1</version>
</dependency>

若要使用 tk.mybatis.spring.annotation.MapperScan,则需要添加通用 Mapper 的依赖:

<dependency>
    <groupId>tk.mybatis</groupId>
    <artifactId>mapper-spring-boot-starter</artifactId>
    <version>2.3.5</version>
</dependency>

4.引用

参考文章链接:https://blog.youkuaiyun.com/qq_37495786/article/details/83448614

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值