mybatis_pagehelper插件

pom.xml

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

application.yml的配制

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

在java类中使用

public List<TApp> findAll(){
		Page<TApp> page=PageHelper.startPage(2,2).setOrderBy("createTime desc");
		List<TApp> tAppList = tAppMapper.findAll();
		System.out.println("total="+page.getTotal());
		return  tAppList;
}

注意PageHelper.startPage 的下方一定要紧跟mapper的查询语句  不能加入其它的代码 否则会引发异常

猜你喜欢

转载自blog.csdn.net/maqingbin8888/article/details/82907659