SoFunction
Updated on 2025-04-13

Mybatis-plus pagination problem is solved

Yesterday, I was working on a new project and using mybatis-plus pagination failed. Later, after multiple investigations, the problem was determined and solved:

Problems with configuring paging plugins

The dividing line of version 3.4.0, the pagination configuration required for different versions of mybatis-plus is different;

Ideas:

First check the dependency version of your project mybatis-plus pagination:

That's mine

            <!--mybatis-plus-->
            <dependency>
                <groupId></groupId>
                <artifactId>mybatis-plus-boot-starter</artifactId>
                <version>3.5.3</version>
                <exclusions>
                    <exclusion>
                        <groupId></groupId>
                        <artifactId>mybatis-plus-generator</artifactId>
                    </exclusion>
                    <exclusion>
                        <artifactId>jsqlparser</artifactId>
                        <groupId></groupId>
                    </exclusion>
                </exclusions>
            </dependency>

Paging plugin configuration for older versions (before 3.4.0)

@Configuration
public class MybatisPlusConfig {

    /**
      * Pagination plugin
      */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}

Pagination plug-in configuration for new version (after 3.4.0)

@Configuration
public class MybatisPlusConfig {

    /**
      * mybatis-plus pagination plugin
      */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        (new PaginationInnerInterceptor());
        return interceptor;
    }

}

Get this thing right, solve the problem, and be beautiful! ! ! ! ! ! ! ! ! !

This is the article about solving the problem of invalid mybatis-plus pagination. For more related invalid mybatis-plus pagination, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!