- 创建分页插件所在的类MybatisPlusConfiguration,并添加注解
@Configuration
- 在配置类中添加以下代码
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
/**
* MybatisPlusInterceptor是插件主体,管理所有的插件
*/
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
/**
* 创建分页插件
*/
PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
/**
* 溢出总页数后按最大页处理
*/
paginationInnerInterceptor.setOverflow(true);
//把分页插件设置给插件主体
interceptor.addInnerInterceptor(paginationInnerInterceptor);
return interceptor;
}
标签:插件,分页,Spring,Boot,MybatisPlusInterceptor,paginationInnerInterceptor,interceptor
From: https://www.cnblogs.com/insilently/p/17511117.html