【Mybatis-plus系列】使用Mybatis-plus的selectPage分页查询没生效

时间:2025-04-11 19:03:39

热门系列:

  • 程序人生,精彩抢先看


1、问题

        最近尝试使用Mybatis-plus的selectPage()分页查询功能,然后发现按照API文档使用后,并没有生效。代码如下:

List<Line> lineList = (new Page<>(1,6),query).getRecords();

        但是发现打印日志,并没有加上limit语句查询。(博主用的是Mysql数据库)


2、解决

        主要问题出在少了下面这段配置代码,加上即可:

import ;
import ;
import ;

/**
 * @Author: Yangy
 * @Date: 2021/8/18 12:14
 * @Description
 */
@Configuration
public class MybatisPlusConfig {
	
	@Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
	
}

        OK,打完收工~~~