• Mybatis-plus与Mybatis依赖冲突问题解决


    文章目录

    错误描述

    An attempt was made to call a method that does not exist. The attempt was made from the following location:
    
     com.baomidou.mybatisplus.core.MybatisMapperAnnotationBuilder.getLanguageDriver(MybatisMapperAnnotationBuilder.java:369)
    
    The following method did not exist:
    
    com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(Ljava/lang/Class;)Lorg/apache/ibatis/scripting/LanguageDriver;
    
    The method's class, com.baomidou.mybatisplus.core.MybatisConfiguration, is available from the following locations:
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    说明

    SpringBoot版本:2.3.9.RELEASE
    MyBatis-plus版本:3.3.1

    这个问题不是一开始就存在的,在SpringBoot版本2.X是正常的,但是在提升SpringBoot版本后,就出现了这个问题
    在这里插入图片描述

    解决过程

    首先不要果断的下定论这个是什么问题,类似这样的问题可以通过IDEA工具定位一下,鼠标点击【1】位置进入到对应的代码位置,注意要点击右上角提示的Download Source下载源码
    在这里插入图片描述
    待代码下载完毕之后,这里可以很清晰的看到configuration没有getLanguageDriver这个方法,在进入到configuration对象
    在这里插入图片描述
    可以看到最终定位到了上面的位置,然后看到extends关键字可以分析出getLanguageDriver肯定是存在于下面的俩个类中的

    com.baomidou.mybatisplus.core.MybatisConfiguration
    org.apache.ibatis.session.Configuration
    
    • 1
    • 2

    在针对上面俩个包路径分析,可以看到第一个是属于mybatisplus.core依赖下的,第二个是属于mybatis依赖下,于是针对这俩种情况分别做个测试
    1、升级mybatisplus包依赖,但是我这边已经是很高的版本的了,及时升级到最新的版本后依然没有看到getLanguageDriver方法,所以问题不在这里
    2、升级mybatis包,由于引入的mybatis-plus-boot-starter已经集成了MyBatis包,所以这里需要首先将其exclude,然后引入单独的较高版本的MyBatis包依赖

    在这里插入图片描述
    升级完成之后再进入到刚才错误的位置,可以看到已经正常了

    在这里插入图片描述

    可以看到最终这个方法处理逻辑是由父类完成的
    org.apache.ibatis.session.Configuration#getLanguageDriver

  • 相关阅读:
    [VUE3] Element Plus 增删拆改页组件拆解
    esbuild中文文档-基础配置项(General options - Live reload)
    【经验分享】Ubuntu如何设置swap交换
    关于肾结石5个知识介绍
    手机界面设计中12种常用布局 优漫动游
    《算法竞赛进阶指南》 最大子序和
    Linux——kafka常用命令
    尚硅谷尚品项目汇笔记(二)
    【基础语法】C语言、python、Java的输入(仅限控制台)
    Tailwindcss Layout布局相关样式及实战案例,5万字长文,附完整源码和效果截图
  • 原文地址:https://blog.csdn.net/m0_67391521/article/details/126463191