直接上代码开干
前言
分页的时候没有起到作用
mapper查到多少数据就返回多少数据
一、核心原因是pageHelper也需要注入拦截器?
1.spring项目代码
代码如下(示例):
<plugins>
<!-- mybatis-plus拦截器 -->
<plugin interceptor="com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor"/>
<plugin interceptor="com.github.pagehelper.PageInterceptor">
<!-- config params as the following -->
<property name="helperDialect" value="mysql"/>
</plugin>
</plugins>
2.spring-boot项目代码
代码如下(示例):
@Configuration
public class MybatisPlusConfig {
/**
* 配置分页插件
*
* @return
*/
@Bean
public MybatisPlusInterceptor innerInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
@Bean
public PageInterceptor pageInterceptor(){
return new PageInterceptor();
}
}
总结
希望能帮助到你,感谢你的点赞