解决方案如下:
1.添加如下配置文件
@Configuration
public class MbConfig {
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
2.去掉pom.xml中的pagehelper插件
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper.spring.boot.version}</version>
</dependency>
3.执行顺序一定要对
Page<Users> usersPage=new Page<>(1,2);
usersDao.selectPage(usersPage,null);
System.out.println(usersPage.getCurrent());
System.out.println(usersPage.getTotal());