import com.github.pagehelper.PageInterceptor;
import org.mybatis.spring.SqlSessionFactoryBean;
//分页插件
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
PageInterceptor interceptor = new PageInterceptor();
Properties properties = new Properties();
properties.setProperty("helperDialect", "sqlserver");
properties.setProperty("reasonable", "true");
properties.setProperty("supportMethodsArguments", "true");
properties.setProperty("count", "countSql");
interceptor.setProperties(properties);
bean.setPlugins(new PageInterceptor[] {
interceptor});
如果提示 在系统中发现了多个分页插件,请检查系统配置!
则启动类排除PageHelperAutoConfiguration
import com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration;
@SpringBootApplication(exclude=
PageHelperAutoConfiguration.class
})