解决mybatis plus 3.x 和pagehelper无法共用、包冲突问题

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


		    com.github.pagehelper
		    pagehelper
		    5.1.10
		
		
		
		    com.github.jsqlparser
		    jsqlparser
		    2.1
		
		
		

		
	        com.baomidou
	        mybatis-plus-boot-starter
	        ${mybatis-plus.version}
	    

不要使用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());
				}
	        };
	    }

}

 

你可能感兴趣的:(微服务,web开发,JAVA,mybatis,plus,pagehelper,spring,boot)