SpringBoot mybatis 自定义分页插件 注解版
1.要使用4.1版本以上的,否则可能不生效
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>4.1.0</version>
</dependency>
@EnableTransactionManagement
@Configuration
public class MybatisPlusConfig {
/**
* 注册分页插件
* @return
*/
/**
* 注册MyBatis分页插件PageHelper
*/
private static String dialect = "dialect";
private static String offsetAsPageNum = "offsetAsPageNum";
private static String rowBoundsWithCount = "rowBoundsWithCount";
private static String reasonable = "reasonable";
private static String database = "mysql";
private static String t = "true";
@Bean
public PageHelper pageHelper() {
PageHelper pageHelper = new PageHelper();
Properties p = new Properties();
p.setProperty(dialect, database);
p.setProperty(offsetAsPageNum, t);
p.setProperty(rowBoundsWithCount, t);
p.setProperty(reasonable, t);
pageHelper.setProperties(p);
return pageHelper;
}