按照mybatis-plus(https://mp.baomidou.com/guide/page.html
)官方推荐搭建好之后,每次请求都会返回全部数据;
解决方案
在构建SqlSessionFactory时加上下面代码
@Autowired
PaginationInterceptor paginationInterceptor;
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean ();
........
// 设置 MyBatis-Plus 分页插件
Interceptor[] plugins = {paginationInterceptor};
factoryBean.setPlugins(plugins);
return factoryBean.getObject();
}
网友评论