当你在加入分页配置,如下:
@Configuration
public class MybatisPlusConfig {
/**
* mybatis-plus分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor page = new PaginationInterceptor();
return page;
}
}
加入以上配置后还是无效,那就用终极解决办法!!!
在数据源的配置中,显示加入分页插件!!!
@Bean("scootSqlSessionFactory")
public SqlSessionFactory scootSqlSessionFactory(@Qualifier("scottDataSource") DataSource scottDataSource) throws Exception {
MybatisSqlSessionFactoryBean sessionFactoryBean = new MybatisSqlSessionFactoryBean();
sessionFactoryBean.setDataSource(scottDataSource);
sessionFactoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(SCOTTConfig.MAPPER_LOCATION));
//下面这一行!!!
sessionFactoryBean.setPlugins(new Interceptor[]{new PaginationInterceptor()});//这一行!!!
//上面这一行!!!
return sessionFactoryBean.getObject();
}
解决:
Page{records=[{LOC=NEW YORK, DEPTNO=11, DNAME=ACCOUNTING, ROW_ID=1}, {LOC=DALLAS, DEPTNO=22, DNAME=RESEARCH, ROW_ID=2}, {LOC=CHICAGO, DEPTNO=33, DNAME=SALES, ROW_ID=3}, {LOC=BOSTON, DEPTNO=44, DNAME=OPERATIONS, ROW_ID=4}], total=4, size=10, current=1}