1、 SpringBoot集成Mybatis Generator
2、SpringBoot集成pageHelper
只需要加入pageHelper的springboot依赖即可
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
注意版本问题:对于SpringBoot2.6以上版本,pagehelper的版本必须是1.4.1以上的,否则会有循环依赖错误,导致程序起不来。
引入pagehelper后使用:
只需在执行sql之前,加入PageHelper.startPage(page, pageSize)
即可,如下图所示:
注意点:
- PageHelper.startPage()只作用于最近的一条sql语句,后面的sql语句并不会触发!!