當你在加入分頁配置,如下:
@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}