【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 分钟前
Bun v1.4.4 实测:2,025 个文件,bun fmt 2.6 秒跑完
前端·后端·bun
萧瑟余晖44 分钟前
Spring Data JPA高级特性详解
后端·spring
利威尔xu1 小时前
Go IM 源码实战(2):WebSocket 握手 11 步,少 1 个参数连不上
后端·websocket·微服务·面试·golang
轻舟技术A1 小时前
Rust 重写 Pi:会话启动耗时降 91%,就绪内存少 78%
开发语言·后端·rust
傲文博一2 小时前
MySQL 不开放外网端口,Mac 怎么连接?
后端
付威20232 小时前
Rust 重写 Pi:会话启动耗时降 91%,就绪内存少 78%
后端
绝望的蛋炒饭2 小时前
长会话的模型选型:缓存命中率如何决定真实成本
人工智能·后端·agent
用户80467718009752 小时前
Spring MVC Controller 返回值类型全解
后端
用户127653018142 小时前
把客服分流、询盘清洗、多平台改写做成 3 个 HTTP 接口,纯规则引擎也能跑
后端