【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>
相关推荐
你的人类朋友5 小时前
说说git的变基
前端·git·后端
阿杆6 小时前
玩转 Amazon ElastiCache 免费套餐:小白也能上手
后端
阿杆6 小时前
无服务器每日自动推送 B 站热门视频
后端
公众号_醉鱼Java7 小时前
Elasticsearch 字段膨胀使用 Flattened类型
后端·掘金·金石计划
JohnYan7 小时前
工作笔记 - CentOS7环境运行Bun应用
javascript·后端·容器
探索java8 小时前
Netty Channel详解:从原理到实践
java·后端·netty
追逐时光者8 小时前
2025 年全面的 C#/.NET/.NET Core 学习路线集合,学习不迷路!
后端·.net
ankleless9 小时前
Spring Boot 实战:从项目搭建到部署优化
java·spring boot·后端
百锦再10 小时前
一文精通 Swagger 在 .NET 中的全方位配置与应用
后端·ui·.net·接口·配置·swagger·访问
用户48221371677510 小时前
C++——静态数组、动态数组
后端