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());
- }
- };
- }
-
- }
- 本文作者: reiner
- 本文链接: https://reiner.host/posts/7bf19d56.html
- 版权声明: 转载请注明出处,并附上原文链接