1、引入POM

1 <dependency>
2     <groupId>com.github.pagehelper</groupId>
3     <artifactId>pagehelper</artifactId>
4     <version>5.2.0</version>
5 </dependency>

2、Mybatis添加PageHepler配置

@Bean
public PageInterceptor pageInterceptor(){
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties=new Properties();
        properties.setProperty("helperDialect","mysql");
        properties.setProperty("helperDialect","mysql");
        properties.setProperty("reasonable","true");
        properties.setProperty("supportMethodsArguments","true");
        properties.setProperty("params","count=countSql");
        pageInterceptor.setProperties(properties);
        return pageInterceptor;
}

3、代码中使用

public PageInfo<OauthClientDetail> listByPage(Integer page, Integer limit){
        PageHelper.startPage(page,limit);
        List<OauthClientDetail> oauthClientDetails = oauthClientDetailsMapper.listByPage();
        return PageInfo.of(oauthClientDetails);
    、}

 

posted on 2021-08-27 23:47  nebula_buck  阅读(100)  评论(0编辑  收藏  举报