Skip to content

Commit 43c8048

Browse files
committed
解决 @AutoConfigureAfter 错误用法导致的问题。
1 parent 4ecfc48 commit 43c8048

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xmlns="http://maven.apache.org/POM/4.0.0"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

@@ -20,7 +20,7 @@
2020
<mybatis.version>3.3.1</mybatis.version>
2121
<mybatis.spring.version>1.2.4</mybatis.spring.version>
2222
<mapper.version>3.3.6</mapper.version>
23-
<pagehelper.version>4.1.1</pagehelper.version>
23+
<pagehelper.version>5.0.0-rc2</pagehelper.version>
2424
</properties>
2525

2626
<dependencies>

src/main/java/tk/mybatis/autoconfigure/MyBatisConfig.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
package tk.mybatis.autoconfigure;
2626

27-
import com.github.pagehelper.PageHelper;
27+
import com.github.pagehelper.PageInterceptor;
2828
import org.apache.ibatis.plugin.Interceptor;
2929
import org.apache.ibatis.session.SqlSessionFactory;
3030
import org.mybatis.spring.SqlSessionFactoryBean;
@@ -67,16 +67,16 @@ public SqlSessionFactory sqlSessionFactoryBean() {
6767
bean.setTypeAliasesPackage("tk.mybatis.springboot.model");
6868

6969
//分页插件
70-
PageHelper pageHelper = new PageHelper();
70+
PageInterceptor interceptor = new PageInterceptor();
7171
Properties properties = new Properties();
7272
properties.setProperty("reasonable", "true");
7373
properties.setProperty("supportMethodsArguments", "true");
7474
properties.setProperty("returnPageInfo", "check");
7575
properties.setProperty("params", "count=countSql");
76-
pageHelper.setProperties(properties);
76+
interceptor.setProperties(properties);
7777

7878
//添加插件
79-
bean.setPlugins(new Interceptor[]{pageHelper});
79+
bean.setPlugins(new Interceptor[]{interceptor});
8080

8181
//添加XML目录
8282
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();

src/main/java/tk/mybatis/springboot/service/CityService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@
2828
import org.springframework.beans.factory.annotation.Autowired;
2929
import org.springframework.stereotype.Service;
3030
import tk.mybatis.springboot.mapper.CityMapper;
31-
import tk.mybatis.springboot.mapper.CountryMapper;
3231
import tk.mybatis.springboot.model.City;
33-
import tk.mybatis.springboot.model.Country;
3432

3533
import java.util.List;
3634

@@ -46,7 +44,7 @@ public class CityService {
4644

4745
public List<City> getAll(City city) {
4846
if (city.getPage() != null && city.getRows() != null) {
49-
PageHelper.startPage(city.getPage(), city.getRows(), "id");
47+
PageHelper.startPage(city.getPage(), city.getRows());
5048
}
5149
return cityMapper.selectAll();
5250
}

src/main/java/tk/mybatis/springboot/service/CountryService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class CountryService {
4444

4545
public List<Country> getAll(Country country) {
4646
if (country.getPage() != null && country.getRows() != null) {
47-
PageHelper.startPage(country.getPage(), country.getRows(), "id");
47+
PageHelper.startPage(country.getPage(), country.getRows());
4848
}
4949
return countryMapper.selectAll();
5050
}

src/main/java/tk/mybatis/springboot/service/UserInfoService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class UserInfoService {
4444

4545
public List<UserInfo> getAll(UserInfo UserInfo) {
4646
if (UserInfo.getPage() != null && UserInfo.getRows() != null) {
47-
PageHelper.startPage(UserInfo.getPage(), UserInfo.getRows(), "id");
47+
PageHelper.startPage(UserInfo.getPage(), UserInfo.getRows());
4848
}
4949
return userInfoMapper.selectAll();
5050
}

0 commit comments

Comments
 (0)