MyBatisPlusConfig中配置分页插件

@Configuration //配置类
@EnableTransactionManagement
@MapperScan("com.atguigu.eduservice.mapper")
public class EduConfig {

    /**
     * 逻辑删除插件
     */
    @Bean
    public ISqlInjector sqlInjector() {
        return new LogicSqlInjector();
    }

    /**
     * 分页插件
     */
    @Bean
    public PaginationInterceptor paginationInterceptor() {
        return new PaginationInterceptor();
    }
}

测试

@Test
    public void testSelectPage() {

        Page<User> page = new Page<>(1,3);  //当前页对象,每页3个
        mpMapper.selectPage(page, null);

        page.getRecords().forEach(System.out::println); //获取当前页对象遍历打印
      
    }
原文地址:https://www.cnblogs.com/fxzemmm/p/14418293.html