1.去官网复制分页内容
2.拷贝到配置类中
//配置类
@Configuration
@MapperScan("com.bot.demo.mapper")
public class MybatisPlusConfig {
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
return interceptor;
}
}
3.就可以使用了
Page<Product> page=new Page<>(pageNum,pageSize);
//查询条件
QueryWrapper<Product> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("discribe","123");
//使用service查询
page= productService.page(page,queryWrapper);
//使用mapper查询
//mapper .selectPahe(page,) 后面是查询条件,没有则为null
return page;