当前位置: 首页 > news >正文

MybatisPlus和pagehelper分页冲突—关于jsqlparser、pagehelper、MybatisPlus三者的版本兼容问题

1 问题描述

        今天在集成pagehelper依赖时,遇到问题,程序查询数据库时报错找不到jsqlparser类,下面是项目相关依赖:

    <properties>           <mybatis-plus.version>3.5.7</mybatis-plus.version><pagehelper.boot.version>2.1.1</pagehelper.boot.version></properties>
            <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId><version>${mybatis-plus.version}</version></dependency><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>${pagehelper.boot.version}</version></dependency>

2 解决方法

2.1 问题原因

        使用Maven Helper插件查看pom文件的依赖,发现依赖冲突:

        pagehelper-spring-boot-starter依赖集成的jsqlparser是4.7版本(这也是目前pagehelper-spring-boot-starter最新版本2.1.1的支持依赖,截止2025-10-5)。

        而mybatis-plus-spring-boot3-starter集成的jsqlparser是4.9版本,因此低版本无法向高版本兼容。

        对于pagehelper-spring-boot-starter内部也集成了mybatis-plus-spring-boot-starter的依赖,但是版本较低:

2.2 解决方案

2.2.1 方案1

        放弃使用pagehelper,mybatisplus的分页功能也很强大,直接使用mybatisplus即可。

2.2.2 方案2

        在发生依赖冲突的地方,右键,选择Exclude排除冲突依赖:

        只能通过这种方式排除pagehelper-spring-boot-starter依赖集成的mybatis-plus依赖与项目中集成的mybatis-plus依赖版本兼容冲突。

        由于pagehelper-spring-boot-starter依赖目前最高只支持4.7版本的jsqlparser,因此不能只排除pagehelper-spring-boot-starter依赖的jsqlparser冲突,同时需要排除mybatis-plus依赖的jsqlparser冲突:

            <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId><version>${mybatis-plus.version}</version><exclusions><exclusion><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId></exclusion></exclusions></dependency><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-starter</artifactId><version>${pagehelper.boot.version}</version><exclusions><exclusion><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId></exclusion><exclusion><artifactId>mybatis</artifactId><groupId>org.mybatis</groupId></exclusion><exclusion><artifactId>mybatis-spring</artifactId><groupId>org.mybatis</groupId></exclusion></exclusions></dependency><!-- 此处需要指定jsqlparser版本为4.7,防止pagehelper集成的jsqlparser版本与mybatisplus集成的jsqlparser版本冲突 --><dependency><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId><version>${jsqlparser.version}</version></dependency>
    <properties>           <jsqlparser.version>4.7</jsqlparser.version><mybatis-plus.version>3.5.7</mybatis-plus.version><pagehelper.boot.version>2.1.1</pagehelper.boot.version></properties>

2.2.3 方案3

        不使用pagehelper-spring-boot-starter依赖,直接使用pagehelper依赖,排除mybatis-plus集成的jsqlparser,并引入jsqlparser依赖与mybatis-plus、pagehelper兼容的版本:

            <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-spring-boot3-starter</artifactId><version>${mybatis-plus.version}</version><exclusions><exclusion><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId></exclusion></exclusions></dependency><dependency><groupId>com.github.pagehelper</groupId><artifactId>pagehelper</artifactId><version>${pagehelper.version}</version></dependency><!-- 此处需要指定jsqlparser版本为4.7,防止pagehelper集成的jsqlparser版本与mybatisplus集成的jsqlparser版本冲突 --><dependency><groupId>com.github.jsqlparser</groupId><artifactId>jsqlparser</artifactId><version>${jsqlparser.version}</version></dependency>
    <properties>           <jsqlparser.version>4.7</jsqlparser.version><mybatis-plus.version>3.5.7</mybatis-plus.version><pagehelper.version>6.1.1</pagehelper.version></properties>
http://www.dtcms.com/a/445888.html

相关文章:

  • R 数组:深入解析与高效使用
  • 缩点学习笔记
  • Go基础:用Go语言操作MongoDB详解
  • 第六章:适配器模式 - 接口转换的艺术大师
  • ARM环境日志系统的简单设计思路
  • 网站名称推荐大气聚财的公司名字
  • 【JVM】——实战篇
  • 那里有正规网站开发培训学校个人网站是怎么样的
  • 高端网站设计简介推荐外贸网站建设的公司
  • asp.net 网站安装工商核名在哪个网站
  • 基于websocket的多用户网页五子棋(五)
  • 【图像处理基石】什么是全景视觉?
  • 【Linux】线程同步和生产者消费者模型
  • 《嵌入式驱动(三):字符设备驱动开发》
  • 做的网站提示磁盘空间不足投票活动网站怎么做
  • 项目1:FFMPEG推流器讲解(二):FFMPEG输出模块初始化
  • 中级前端进阶方向 框架篇 三十四) 前端自动化测试 + 【步骤落地 + 了解】
  • 【开题答辩全过程】以 python杭州亚运会数据分析与可视化开题为例,包含答辩的问题和答案
  • 中国做外贸网站有哪些网站下雪的效果怎么做的
  • XSLT `<choose>` 元素详解
  • 汽车零部件英语词汇 | 3000 最常用单词系列
  • 深圳优秀网站建设价格网站视频开发平台
  • 菏泽最好的网站建设公司安徽建设工程信息网查
  • Video-of-Thought论文阅读
  • 做下载类型网站怎样划算做网站常用的技术有哪些
  • stp instance 0 cost 5000 概念及题目
  • KVM创建的虚拟机,虚拟机的网卡是如何生成的
  • 网站开发人员结构清新太和做网站
  • 【开题答辩全过程】以 SportsGo健身网站为例,包含答辩的问题和答案
  • Cobalt Strike