Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.pagehelper:pagehelper-spring-boot:2.1.1'
}
dependencies {
implementation("com.github.pagehelper:pagehelper-spring-boot:2.1.1")
}
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot</artifactId>
<version>2.1.1</version>
</dependency>
libraryDependencies += "com.github.pagehelper" % "pagehelper-spring-boot" % "2.1.1"
:dependencies [[com.github.pagehelper/pagehelper-spring-boot "2.1.1"]]
PageHelper-Spring-Boot-Starter 帮助你集成分页插件到 Spring Boot。
PageHelper-Spring-Boot-Starter will help you use PageHelper with Spring Boot.
Support PageHelper 6.x
在 pom.xml 中添加如下依赖:
Add the following dependency to your pom.xml:
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>4.1.0</version>
</dependency>
debug、countSuffix、countMsIdGen、msCountCache、aggregateFunctions、asyncCountParallelism当前版本支持 JDK17+ 和以下依赖版本:
orderBySqlParser,OrderBySqlParser改为接口,允许通过orderBySqlParser参数替换为自己的实现sqlServerSqlParser,SqlServerSqlParser改为接口,允许通过sqlServerSqlParser参数替换为自己的实现CountSqlParser,OrderBySqlParser,SqlServerSqlParser 还支持SPI方式覆盖默认实现,优先级低于参数指定asyncCount,增加异步count支持,默认false,单次设置:PageHelper.startPage(1, 10).enableAsyncCount();countSqlParser,CountSqlParser改为接口,允许通过countSqlParser参数替换为自己的实现参数示例:
pagehelper.async-count=true
autoDialectClass 参数,详情看 PageHelper 更新日志PageHelperAutoConfiguration 使用 InitializingBean 接口代替 @PostConstruct 注解PageHelperAutoConfiguration 增加 @Lazy(false) 注解,当配置延迟加载时,避免分页插件出错v1.2.8 由于未修改版本,仍然和 v1.2.7 相同。
增加 dialectAlias 参数,允许配置自定义实现的 别名,可以用于根据JDBCURL自动获取对应实现,允许通过此种方式覆盖已有的实现,配置示例如(多个配置用分号;隔开):
pagehelper.dialect-alias=oracle=com.github.pagehelper.dialect.helper.OracleDialect
增加 defaultCount 参数,用于控制默认不带 count 查询的方法中,是否执行 count 查询,默认 true 会执行 count 查询,这是一个全局生效的参数,多数据源时也是统一的行为。配置示例如:
pagehelper.default-count=false
PageHelperAutoConfiguration 类中的 @Override 报错问题。
https://github.com/abel533/MyBatis-Spring-Boot
https://github.com/pagehelper/Mybatis-PageHelper
一般情况下,你不需要做任何配置。
Normally, you don't need to do any configuration.
如果需要配置,可以使用如下方式进行配置:
You can config PageHelper as the following:
application.properties:
pagehelper.propertyName=propertyValue
注意 pagehelper 配置,大部分常用参数支持 IDE 自动提示和 kebab-case 风格配置(如 offset-as-page-num),
如果自己扩展了分页插件参数,对于无法自动提示的参数,直接使用原始参数名配置即可。
关于可配置的属性请参考 如何使用分页插件。
You can configure the properties of the reference here How to use the PageHelper.
如果你想要控制 拦截器插件的顺序,可以通过下面注解控制:
If you want to control the order in which the interceptor plug-in, you can use the following annotation control:
@AutoConfigureAfter(PageHelperAutoConfiguration.class)
//Or
@AutoConfigureBefore(PageHelperAutoConfiguration.class)