@EnableAutoConfiguration
//开不开都一样默认开启
@MapperScan(value = "com.ccc.mapper")
public class MainConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
}
先添加mybatis-plus的分页插件
@Test
public void testlist(){
Page<user> userPage = new Page<>(1, 3);
usermapper.selectPage(userPage,null);
userPage.getRecords().forEach(System.out::println);
}
分页查询