MyBatis 使用PageHelper分頁不起作用
阿新 • • 發佈:2018-12-23
記錄一個坑爹的問題,springboot壞境下使用PageHelper不起作用
PageHelper.startPage(pageNo,pageSize)
上面語句跟隨的mapper查出來的總是所有資料,並沒有分頁。
排查之後發現問題出在pom檔案依賴錯了,springboot壞境要用
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>{springbootPageHelper.version}</version></dependency>
而不是原來的
<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper</artifactId> <version>{pagehelper.version}</version> </dependency>
因為上面的依賴缺少了
<dependency> <groupId>com.github.pagehelper</groupId><artifactId>pagehelper-spring-boot-autoconfigure</artifactId> </dependency>