Springboot project PageHelper is upgraded to version 5.3.2, paging query fails

Springboot project PageHelper is upgraded to version 5.3.2, paging query fails

Online Troubleshooting

Background : The phenomenon is that the gateway reported an error FluxOnAssembly$OnAssemblyException. After investigation, it was found that more than 2,000 pieces of data were returned during the pagination query, which caused the amount of data to exceed the limit of the gateway, thus throwing an error. That is, the pageHelper pagination query does not take effect .

Reason : The configuration method of pageHelper has changed after upgrading to version 5.3.2

  • The configuration method of the lower version is as follows

  • @Configuration
    public class PageHelperConfig {
          
          
        @Bean
        public PageHelper pageHelper() {
          
          
            PageHelper pageHelper = new PageHelper();
            Properties properties = new Properties();
            properties.setProperty("offsetAsPageNum", "true");
            properties.setProperty("rowBoundsWithCount", "true");
            properties.setProperty("reasonable", "true");
            //配置mysql数据库的方言
            properties.setProperty("dialect", "mysql");
            pageHelper.setProperties(properties);
            return pageHelper;
        }
    }
    

Solution:

  • Change PageHelper to register via PageInterceptor

  • @Configuration
    public class PageHelperConfig {
          
          
        @Bean
        public PageInterceptor pageInterceptor(){
          
          
            PageInterceptor pageInterceptor = new PageInterceptor();
            Properties properties = new Properties();
            properties.setProperty("offsetAsPageNum", "true");
            properties.setProperty("rowBoundsWithCount", "true");
            properties.setProperty("reasonable", "true");
            //配置mysql数据库的方言
            properties.setProperty("helperDialect", "mysql");
            pageInterceptor.setProperties(properties);
            return pageInterceptor;
        }
    }
    

Guess you like

Origin blog.csdn.net/qq_28959087/article/details/131784234