Skip to content

Commit 5ba9533

Browse files
committed
feat: 集成 pagehelper
1 parent fa4276f commit 5ba9533

5 files changed

Lines changed: 23 additions & 6 deletions

File tree

application/src/main/java/top/cadecode/uniboot/UniBootApplication.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
package top.cadecode.uniboot;
22

3+
import org.mybatis.spring.annotation.MapperScan;
34
import org.springframework.boot.SpringApplication;
45
import org.springframework.boot.autoconfigure.SpringBootApplication;
56
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
67
import org.springframework.boot.builder.SpringApplicationBuilder;
78
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
8-
import org.springframework.context.annotation.ComponentScan;
99
import org.springframework.context.annotation.EnableAspectJAutoProxy;
1010

1111
/**
1212
*
1313
*/
14-
@ComponentScan("top.cadecode")
14+
@MapperScan("top.decode.**.mapper")
1515
@EnableAspectJAutoProxy(exposeProxy = true)
1616
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
1717
public class UniBootApplication extends SpringBootServletInitializer {

application/src/main/resources/application.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ spring:
4747
config:
4848
multi-statement-allow: true
4949

50+
# pagehelper
51+
pagehelper:
52+
reasonable: true
53+
supportMethodsArguments: true
54+
params: count=countSql
55+
auto-dialect: true
56+
auto-runtime-dialect: true
57+
5058
# mybatis plus 配置
5159
mybatis-plus:
5260
mapper-locations: classpath*:mapper/**/*.xml

common/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@
6262
<groupId>org.mybatis.spring.boot</groupId>
6363
<artifactId>mybatis-spring-boot-starter</artifactId>
6464
</dependency>
65+
<!--pagehelper-->
66+
<dependency>
67+
<groupId>com.github.pagehelper</groupId>
68+
<artifactId>pagehelper-spring-boot-starter</artifactId>
69+
</dependency>
6570
<!--mybatis plus-->
6671
<dependency>
6772
<groupId>com.baomidou</groupId>
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
package top.cadecode.uniboot.framework.config;
22

3-
import com.baomidou.mybatisplus.annotation.DbType;
43
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
54
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
6-
import org.mybatis.spring.annotation.MapperScan;
75
import org.springframework.context.annotation.Bean;
86
import org.springframework.context.annotation.Configuration;
97

@@ -14,15 +12,14 @@
1412
* @date 2022/2/16
1513
*/
1614
@Configuration
17-
@MapperScan("top.cadecode.**.mapper")
1815
public class MybatisConfig {
1916
/**
2017
* Mybatis Plus 插件配置
2118
*/
2219
@Bean
2320
public MybatisPlusInterceptor mybatisPlusInterceptor() {
2421
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
25-
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
22+
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
2623
return interceptor;
2724
}
2825
}

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<vavr.vsersion>1.0.0-alpha-4</vavr.vsersion>
3838
<knife4j.version>2.0.5</knife4j.version>
3939
<mybatis.version>2.2.0</mybatis.version>
40+
<pagehelper.version>1.4.0</pagehelper.version>
4041
<mybatis-plus.version>3.5.1</mybatis-plus.version>
4142
<p6spy.version>3.8.1</p6spy.version>
4243
<jasypt.version>2.1.1</jasypt.version>
@@ -124,6 +125,12 @@
124125
<artifactId>mybatis-spring-boot-starter</artifactId>
125126
<version>${mybatis.version}</version>
126127
</dependency>
128+
<!--pagehelper-->
129+
<dependency>
130+
<groupId>com.github.pagehelper</groupId>
131+
<artifactId>pagehelper-spring-boot-starter</artifactId>
132+
<version>${pagehelper.version}</version>
133+
</dependency>
127134
<!--mybatis plus-->
128135
<dependency>
129136
<groupId>com.baomidou</groupId>

0 commit comments

Comments
 (0)