pagehelper-sprng-boot-starter 和mybatis-plus-spring-boot-starter 同时引入启动时会报错,即使按网上的排出pagehelper-starter的mybatis包依旧报错,具体解决办法如下:

<dependency>
		    <groupId>com.github.pagehelper</groupId>
		    <artifactId>pagehelper</artifactId>
		    <version>5.1.10</version>
		</dependency>
		<!-- pagehelper 依赖 -->
		<dependency>
		    <groupId>com.github.jsqlparser</groupId>
		    <artifactId>jsqlparser</artifactId>
		    <version>2.1</version>
		</dependency>
		
		

		<dependency>
	        <groupId>com.baomidou</groupId>
	        <artifactId>mybatis-plus-boot-starter</artifactId>
	        <version>${mybatis-plus.version}</version>
	    </dependency>

不要使用pagehelper-starter 

然后手动添加pagehelper mybatis拦截器:

package com.xh.sdk.springcloud.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.baomidou.mybatisplus.autoconfigure.ConfigurationCustomizer;
import com.baomidou.mybatisplus.core.MybatisConfiguration;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;

@Configuration
public class MyBatisPlusConfig {

	 /*
	    * 分页插件,自动识别数据库类型
	    * 多租户,请参考官网【插件扩展】
	    */
	   @Bean
	   public PaginationInterceptor paginationInterceptor() {
	      return new PaginationInterceptor();
	   }
	   

	   @Bean
	    ConfigurationCustomizer mybatisConfigurationCustomizer() {
	        return new ConfigurationCustomizer() {
				@Override
				public void customize(MybatisConfiguration configuration) {
					configuration.addInterceptor(new com.github.pagehelper.PageInterceptor());
				}
	        };
	    }

}

 

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐