我是靠谱客的博主 丰富手套,这篇文章主要介绍扩展:SpringBoot+MyBatis框架+PageHelper分页模板的整合,现在分享给大家,希望可以做个参考。

1.依赖:
<!--分页插件-->
<dependency>
   <groupId>com.github.pagehelper</groupId>
   <artifactId>pagehelper-spring-boot-starter</artifactId>
   <version>RELEASE</version>
</dependency>
2.使用 pagehelper
创建UserMapper接口
@Mapper
public interface UserMapper extends CommonMapper<User>{

    @Select("SELECT * FROM t_user")
    public List<User> getListSecond();
}
测试:
@RunWith(SpringRunner.class)
@SpringBootTest
public class Demo2ApplicationTests {

   @Autowired
   private UserMapper userMapper;
   
   @Test
   public void getListSecond(){
       PageHelper.offsetPage(0,5);
      List<User> list =userMapper.getListSecond();
      for (User user:list){
         System.out.println(user.getName()+":"+user.getPassword()+":"+user.getPhone());
      }
   }
}
结果只打印前五条,测试成功

最后

以上就是丰富手套最近收集整理的关于扩展:SpringBoot+MyBatis框架+PageHelper分页模板的整合的全部内容,更多相关扩展:SpringBoot+MyBatis框架+PageHelper分页模板内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部