Mybatis-plus分页

添加依赖

        
            com.baomidou
            mybatis-plus-boot-starter
            3.4.0
        

在启动类编辑

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }

Mapper层编写

IPage getList(Page page); 
 

xml文件编写SQL

    

Test测试

    @Test
    void Test01(){
        Page page = new Page<>(0, 2);
        List records = userMapper.getList(page).getRecords();
        records.forEach(item->System.out.println(item));
    } 

                            
                        
                    
                    
                    

你可能感兴趣的:(mybatis-plus)