最近在SpringBoot项目和Spring项目同时开发,两个项目都依赖了Mybatis框架里的pagehelper分页插件,但是SpringBoot项目分页不起作用,一直查询出所有数据。
错误原因:两项目都引入的依赖为
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.0.0</version>
</dependency>
解决办法:经过多次调查试验,发现SpringBoot项目依赖的分页插件和Spring项目有所不同,需要spring-boot-starter下的包才可以。所以SpringBoot项目需要配置下面的依赖即可:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.5</version>
</dependency>