本文共 984 字,大约阅读时间需要 3 分钟。
package mybatis.cn.config;import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;/** * @author yanyg * @since 2020/8/19 */@Configurationpublic class MybatisPlusConfig { /** * mp的分页插件 */ @Bean public PaginationInterceptor paginationInterceptor() { return new PaginationInterceptor(); }}
@Testpublic void testSelectByPage() { System.out.println("===========按条件查询============"); QueryWrapper wrapper = new QueryWrapper(); wrapper.eq("name", "七仙女"); wrapper.orderByAsc("id"); IPagepage = new Page<>(1, 3); IPage personsIPage = personsMapper.selectPage(page, wrapper); personsIPage.getRecords().forEach(System.out::println); System.out.println("当前分页总页数===>" + personsIPage.getPages()); System.out.println("总条数===>" + personsIPage.getTotal());}
转载地址:http://wfvli.baihongyu.com/