package com.wzy.bootmtp.test;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wzy.bootmtp.mapper.UserMapper;
import com.wzy.bootmtp.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestSpringBoot {
@Autowired
private UserMapper userMapper;
@Test
public void test2(){
Page<User> page = new Page<>(1,5);
userMapper.selectPage(page, null);
page.getRecords().forEach(System.out::println);
System.out.println("当前页:" + page.getCurrent());
System.out.println("总页码:" + page.getPages());
System.out.println("每页显示数据的个数:" + page.getSize());
System.out.println("总记录数:" + page.getTotal());
System.out.println("是否有下一页:" + page.hasNext());
System.out.println("是否有上一页:" + page.hasPrevious());
}
}
如果执行时间过长,则抛出异常:The SQL execution time is too large,
输出