【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>
相关推荐
用户21411832636023 小时前
Qwen3-Coder 实战!历史人物短视频一键生成,多分镜人物不崩,魔搭直接玩
后端
追逐时光者4 小时前
C#/.NET/.NET Core技术前沿周刊 | 第 54 期(2025年9.8-9.14)
后端·.net
追逐时光者4 小时前
C#/.NET/.NET Core编程技巧练习集,配套详细的文章教程讲解!
后端·.net
AD钙奶-lalala4 小时前
SpringBoot实现WebSocket服务端
spring boot·后端·websocket
moxiaoran57534 小时前
Flask学习笔记(一)
后端·python·flask
你的人类朋友4 小时前
🔒什么是HMAC
后端·安全·程序员
盖世英雄酱581365 小时前
Read timed out问题 排查
java·数据库·后端
BXCQ_xuan6 小时前
软件工程实践二:Spring Boot 知识回顾
java·spring boot·后端
o0o_-_6 小时前
【go/gopls/mcp】官方gopls内置mcp server使用
开发语言·后端·golang
苏三说技术6 小时前
为什么不建议在 Docker 中跑 MySQL?
后端