[java] pagehelper ページングを mybatis-plus ページングと互換性のあるものにする

質問

元の機能インターフェイスを保存できず、次のエラーが発生します。net.sf.jsqlparser.statement.select.SetOperationList cannot be cast to net.sf.jsqlparser.statement.select.PlainSelect

https://mvnrepository.com/artifact/com.github.pagehelper/pagehelper-spring-boot-starter
pagehelper はアップグレードされたバージョン 1.4.6 に依存し、jsqlparser 依存関係を除外しているため、pagehelper ページングは​​ mybatis-plus ページングと互換性があります。

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 バージョン
	<!--mybatis-->
	<dependency>
	    <groupId>com.baomidou</groupId>
	    <artifactId>mybatis-plus-boot-starter</artifactId>
	    <version>3.5.3.2</version>
	</dependency>
  • ページヘルパーのバージョン
	<!--分页封装使用-->
	<dependency>
		<groupId>com.github.pagehelper</groupId>
		<artifactId>pagehelper-spring-boot-starter</artifactId>
		<version>1.4.6</version>
	</dependency>

解決する

依存関係除外処理jsqlparser、mybatis、mybatis-springを実行し、プロジェクトサービスを再実行すると正常になります。

	<!--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>

おすすめ

転載: blog.csdn.net/u010638673/article/details/132191200