jeecgboot 如何配置使用 pagehelper

本文详细介绍了在JeecgBoot项目中如何正确配置PageHelper分页插件,以解决自定义SQL分页问题。通过在pom.xml中手动引入依赖,并在MybatisPlusConfig中添加PageInterceptor拦截器,实现了与mybatis-plus的兼容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jeecgboot 自带的分页插件使用非常方便,但是无法解决自定义 sql 的问题;一般的 springboot 工程使用 pagehelper 分页插件都是通过 pom.xml 引入 pagehelper-spring-boot-starter 依赖 + application.properties 配置 pagehelper相关配置的方式,但是在 jeecgboot 工程中 pagehelper-spring-boot-starter 和 mybatis-plus-spring-boot-starter 同时引入启动时会报错,所以可以采用不使用 pagehelper-starter ,直接使用 pagehelper + 手动添加 pagehelper mybatis 拦截器的方式:

即 pom.xml 中:

<!--pagehelper 分页插件-->
		<dependency>
			<groupId>com.github.pagehelper</groupId>
			<artifactId>pagehelper</artifactId>
			<version>5.1.10</version>
		</dependency>
		<!--pagehelper 内部依赖的 -->
		<dependency>
			<groupId>com.github.jsqlparser</groupId>
			<artifactId>jsqlparser</artifactId>
			<version>2.1</version>
		</dependency>
MybatisPlusConfig 中:
 @Bean
    ConfigurationCustomizer mybatisConfigurationCustomizer() {
        return new ConfigurationCustomizer() {
            @Override
            public void customize(MybatisConfiguration configuration) {
                configuration.addInterceptor(new com.github.pagehelper.PageInterceptor());
            }
        };
    }

使用:

  PageHelper.startPage( pageNo,pageSize );
  List<ProInfo> proInfoList = this.proInfoMapper.queryList( l );
  PageInfo<ProInfo> proInfoPageInfo = new PageInfo<>(proInfoList);

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值