1 版本
spring boot 版本为 2.1.3.RELEASE
mybatis-plus版本为 3.4.0
2 Bean配置
在启动类加入如下配置
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
3 编码
伪代码 Object需要换成你自己的类 mybatis-plus-service 自己对应的service
Page<Object> page = new Page<>(pageNum,pageSize); Page<Object> result = mybatis-plus-service.page(page);