【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>
相关推荐
天天摸鱼的java工程师几秒前
八年 Java 开发经验:反射机制在实际业务中的深度应用解析
java·后端·面试
wjr9205035 分钟前
深入理解Spring Boot中的Filter机制:原理、注册与实战应用
java·spring boot·后端
bobz96512 分钟前
ovs iface-id
后端
熟悉的新风景14 分钟前
SpringBoot使用oshi获取服务器相关信息
服务器·spring boot·后端
天天摸鱼的java工程师18 分钟前
Java 内存模型与垃圾回收场景题实战解析
java·后端
chanalbert19 分钟前
Spring AOP 模块设计文档
后端·spring
CodeSheep22 分钟前
知名开源项目AList疑似被卖,玩家炸锅了!!
前端·后端·程序员
这里有鱼汤1 小时前
为什么我现在做Python项目都用UV?你看完就懂了
后端·python
面朝大海,春不暖,花不开1 小时前
使用Spring Boot Actuator构建用户应用
java·spring boot·后端
寻月隐君1 小时前
探索Solana SDK实战:Web3开发的双路径与轻量模块化
后端·web3·github