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); 、}