When using mybatis and mybatis-plus at the same time, the pageHelper failure problem is solved

Add a class, this class is used to initialize the PageInterceptor class, this time the attempt is successful, and the paged data is returned correctly. code show as below:

import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor; 
import com.github.pagehelper.PageInterceptor; 
import org.springframework.context.annotation.Bean; 
import org.springframework.context.annotation.Configuration; 

import java.util .Properties; 

@Configuration 
public class MyBatisPlusConfig { 

    /* 
     * Pagination plug-in, automatically identify database type 
     * Multi-tenant, please refer to the official website【Plug-in extension】
     */ 
    @Bean 
    public PaginationInnerInterceptor paginationInterceptor() { 
        return new PaginationInnerInterceptor(); 
    } 

    @Bean 
    PageInterceptor pageInterceptor() { 
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties = new Properties(); 
        properties.setProperty("helperDialect", "mysql"); 
        pageInterceptor.setProperties(properties); // Here you can enter the source code, 
        return pageInterceptor; 
    } 
}

Guess you like

Origin blog.csdn.net/zhongguowangzhan/article/details/127007644