【java】使pagehelper分页与mybatis-plus分页兼容存在

问题

原先的功能接口都无法保存,出现如下错误:net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to net.sf.jsqlparser.statement.select.PlainSelect

mvnrepository.com/artifact/co... pagehelper 依赖升级版本1.4.6并且排除jsqlparser依赖,使pagehelper分页与mybatis-plus分页兼容存在

sql 复制代码
xxxx.TenantBroker$TenantBrokerExceptionWrapper: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error updating database.  Cause: java.lang.ClassCastException: net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to net.sf.jsqlparser.statement.select.PlainSelect
### The error may exist in xxxx/SysLogMapper.java (best guess)
### The error may involve xxxx.mapper.SysLogMapper.insert
### The error occurred while executing an update

排查

使用的是mybatis + pageHealper做分页,新增的依赖和原本的mybatis-plus里面依赖是出现依赖冲突

  • mybatis-plus版本
xml 复制代码
	<!--mybatis https://mvnrepository.com/artifact/com.baomidou/mybatis-plus/3.5.3.2 -->
	<dependency>
	    <groupId>com.baomidou</groupId>
	    <artifactId>mybatis-plus-boot-starter</artifactId>
	    <version>3.5.3.2</version>
	</dependency>
  • pagehelper版本
xml 复制代码
	<!--分页封装使用-->
	<dependency>
		<groupId>com.github.pagehelper</groupId>
		<artifactId>pagehelper-spring-boot-starter</artifactId>
		<version>1.4.6</version>
	</dependency>

解决

进行依赖排除处理jsqlparser、mybatis、mybatis-spring,重新运行项目服务后正常

xml 复制代码
	<!--mybatis-->
	<dependency>
	    <groupId>com.baomidou</groupId>
	    <artifactId>mybatis-plus-boot-starter</artifactId>
	    <version>3.5.3.1</version>
	</dependency>
	<!-- pagehelper 分页封装使用 -->
	<!-- pagehelper 依赖升级版本1.4.6并且排除jsqlparser依赖,使pagehelper分页与mybatis-plus分页兼容存在 -->
	<dependency>
		<groupId>com.github.pagehelper</groupId>
		<artifactId>pagehelper-spring-boot-starter</artifactId>
		<version>1.4.6</version>
		<exclusions>
			<exclusion>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis</artifactId>
			</exclusion>
			<exclusion>
				<groupId>org.mybatis</groupId>
				<artifactId>mybatis-spring</artifactId>
			</exclusion>
			<exclusion>
				<groupId>com.github.jsqlparser</groupId>
				<artifactId>jsqlparser</artifactId>
			</exclusion>
		</exclusions>
	</dependency>
相关推荐
烛之武1 小时前
SpringBoot基础
java·spring boot·后端
橙序员小站1 小时前
Harness Engineering:从 OpenClaw 看 AI 助理的基础设施建设
后端·aigc·openai
小陈工1 小时前
2026年3月28日技术资讯洞察:5G-A边缘计算落地、低延迟AI推理革命与工业智造新范式
开发语言·人工智能·后端·python·5g·安全·边缘计算
azhou的代码园2 小时前
基于SpringBoot+微信小程序的图片识别科普系统
spring boot·后端·微信小程序
Tony Bai3 小时前
Rust 看了流泪,AI 看了沉默:扒开 Go 泛型最让你抓狂的“残疾”类型推断
开发语言·人工智能·后端·golang·rust
用户3167361303423 小时前
javaLangchain4j从官方文档入手,看他做了什么——具体使用(二)
后端
無名路人3 小时前
Zsh 脚本 + VS Code 任务:NestJS + Vue3 一键部署到 1Panel
运维·后端·自动化运维
ybwycx4 小时前
springboot之集成Elasticsearch
spring boot·后端·elasticsearch
程途知微4 小时前
AQS 同步器——Java 并发框架的核心底座全解析
java·后端
iPadiPhone5 小时前
分布式架构的“润滑剂”:RabbitMQ 核心原理与大厂面试避坑指南
分布式·后端·面试·架构·rabbitmq