springboot+mybatis整合分页插件PageHelper

1.在pom.xml中引入依赖:

    
        com.github.pagehelper
        pagehelper
        5.0.0
    
    
        com.github.pagehelper
        pagehelper-spring-boot-autoconfigure
        1.2.3
    
    
        com.github.pagehelper
        pagehelper-spring-boot-starter
        1.2.3
    
    

2.在application.propreties加入配置:

pagehelper.helperDialect=mysql pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

3.在controller层中应用

    @GetMapping(value="getListByMap")
public List getListByMap (
        @RequestParam(value="currentPage",required=false,defaultValue="1")Integer currentPage,
        @RequestParam(value="pageSize",required=false,defaultValue="10")Integer pageSize
) throws ParseException {
   
    PageHelper.startPage(currentPage , pageSize);
    List list = zhuanyeService.getListByMap(map);        
    PageInfo pageList = new PageInfo(list); 
    List datas = pageList.getList(); 
    return datas;
}

你可能感兴趣的:(mybatis)