1. package com.wzy.bootmtp.test;
    2. import com.baomidou.mybatisplus.core.metadata.IPage;
    3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
    4. import com.wzy.bootmtp.mapper.UserMapper;
    5. import com.wzy.bootmtp.pojo.User;
    6. import org.junit.Test;
    7. import org.junit.runner.RunWith;
    8. import org.springframework.beans.factory.annotation.Autowired;
    9. import org.springframework.boot.test.context.SpringBootTest;
    10. import org.springframework.test.context.junit4.SpringRunner;
    11. import java.util.Arrays;
    12. import java.util.List;
    13. import java.util.Map;
    14. @RunWith(SpringRunner.class)
    15. @SpringBootTest
    16. public class TestSpringBoot {
    17. @Autowired
    18. private UserMapper userMapper;
    19. @Test
    20. public void test2(){
    21. Page<User> page = new Page<>(1,5);
    22. userMapper.selectPage(page, null);
    23. page.getRecords().forEach(System.out::println);
    24. System.out.println("当前页:" + page.getCurrent());
    25. System.out.println("总页码:" + page.getPages());
    26. System.out.println("每页显示数据的个数:" + page.getSize());
    27. System.out.println("总记录数:" + page.getTotal());
    28. System.out.println("是否有下一页:" + page.hasNext());
    29. System.out.println("是否有上一页:" + page.hasPrevious());
    30. }
    31. }

    image.png
    image.png

    如果执行时间过长,则抛出异常:The SQL execution time is too large,
    输出
    image.png