1 在pom.xml中導入相關的依賴(注意版本問題,報錯十有八九是因為版本問題)
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.3</version> </dependency>
2 在yml配置文件中輸入相關配置
pagehelper:
helper-dialect: mysql
reasonable: true
support-methods-arguments: true
params: count=countSql
3 使用 (個人推薦返回值為PageHelper方式)
3.1 返回page對象(注意,查詢語句必須緊跟着pagehelper語句,否則會報錯。 )
返回的為需要查詢的數據集合
3.2 返回pagehelper對象
返回的值為需要查詢的數據集合以及一系列分頁信息