配置(mybatsi-plus版本不一样,配置方法也不同,具体可到mybatis-plus官方文档查看)
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
return interceptor;
}
测试
@Test
void selectPage(){
Page<User> page = new Page<>(1,2);
Page<User> result = userMapper.selectPage(page,null);
result.getRecords().forEach(System.out::println);
}