mybatisplus自带分页方法无分页效果

1、如果没有自定义SqlSessionFactory类,加配置类即可

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //添加分页插件
        PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor();
        //设置请求的页面大于最大页的操作,true调回首页,false继续请求,默认是false
        pageInterceptor.setOverflow(false);
        //单页分页的条数限制,默认五限制
        pageInterceptor.setMaxLimit(500L);
        //设置数据库类型
        pageInterceptor.setDbType(DbType.MYSQL);

        interceptor.addInnerInterceptor(pageInterceptor);
        return interceptor;
    }

2、如果自定义了SqlSessionFactory类,在配置中加分页插件。

        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //添加分页插件
        PaginationInnerInterceptor pageInterceptor = new PaginationInnerInterceptor();
        pageInterceptor.setDbType(DbType.MYSQL);

        interceptor.addInnerInterceptor(pageInterceptor);

        sessionFactory.setPlugins(interceptor);

完美解决:

猜你喜欢

转载自blog.csdn.net/qq_33767353/article/details/128320323