springboot 整合 PageHelper 分页

1. pom.xml

   com.github.pagehelper

   pagehelper

   5.1.2

   com.github.pagehelper

   pagehelper-spring-boot-autoconfigure

   1.2.3

   com.github.pagehelper

   pagehelper-spring-boot-starter

   1.2.3

 

2. application.yml

pagehelper:

    helperDialect: mysql

   reasonable: true

   supportMethodsArguments: true

   params: count=countSql

 

 

3. ShopMapper.xml 配置

     

       

       

       

     

       

       

       

     

     

     

   

 

 

4. dao 层

@Repository

public interface ShopMapper extends BaseMapper {

     ArrayList  getShopAll();

}

 

5. service 层

public interface ShopService {

    BaseResult getShopAll(Integer pageNum, Integer pageSize);

}

 

6. serviceImpl 层

@Service

public class ShopServiceImpl implements IShopService {

    @Autowired

   private ShopMapper shopMapper;

 

@Override

public BaseResult getShopAll(Integer pageNum, Integer pageSize) {

        PageHelper.startPage(pageNum, pageSize); // 这里是开启分页

       ArrayList list = shopMapper.getShopAll();

       PageInfo pageInfo = new PageInfo(list);

       List shopList = pageInfo.getList();

      return BaseResult.success(shopList);

  }

}

7. 效果图

springboot 整合 PageHelper 分页_第1张图片

 

你可能感兴趣的:(Java学习)