springboot集成pagehelper插件

1.在pom.xml中引入依赖

        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.1.1</version>
        </dependency>        

2.在application.properties配置pagehelper的属性

#pagehelper分页插件配置
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql

使用示例:

  @Override
    public PageInfo<TBrand> getBrandInfo(PageHelpBean pageHelpBean) throws ParameterException{
        if (StringUtils.isEmpty(pageHelpBean.getPageNum()) && StringUtils.isEmpty(pageHelpBean.getPageSize())) {
            throw new ParameterException();
        }
        PageHelper.startPage(pageHelpBean.getPageNum(),pageHelpBean.getPageSize());
        List<TBrand> brandInfo = tBrandMapper.getBrandInfo();
        PageInfo<TBrand> pageInfo = new PageInfo<TBrand>(brandInfo);
        return pageInfo;
    }

来自:https://blog.csdn.net/csdn_huzeliang/article/details/79350425

原文地址:https://www.cnblogs.com/shiguotao-com/p/9915339.html