Mybatis-Plus分页插件失效
2020-06-03 本文已影响0人
trimcode
按照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();
}