diff --git a/pagehelper-spring-boot-autoconfigure/pom.xml b/pagehelper-spring-boot-autoconfigure/pom.xml index d76f942..c815004 100644 --- a/pagehelper-spring-boot-autoconfigure/pom.xml +++ b/pagehelper-spring-boot-autoconfigure/pom.xml @@ -29,7 +29,7 @@ com.github.pagehelper pagehelper-spring-boot - 1.2.3 + 1.2.4-SNAPSHOT pagehelper-spring-boot-autoconfigure pagehelper-spring-boot-autoconfigure diff --git a/pagehelper-spring-boot-autoconfigure/src/main/java/com/github/pagehelper/autoconfigure/PageHelperAutoConfiguration.java b/pagehelper-spring-boot-autoconfigure/src/main/java/com/github/pagehelper/autoconfigure/PageHelperAutoConfiguration.java index b4e1c1c..2a73512 100644 --- a/pagehelper-spring-boot-autoconfigure/src/main/java/com/github/pagehelper/autoconfigure/PageHelperAutoConfiguration.java +++ b/pagehelper-spring-boot-autoconfigure/src/main/java/com/github/pagehelper/autoconfigure/PageHelperAutoConfiguration.java @@ -25,18 +25,13 @@ package com.github.pagehelper.autoconfigure; import com.github.pagehelper.PageInterceptor; -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration; +import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.AutoConfigureAfter; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import javax.annotation.PostConstruct; -import java.util.List; import java.util.Properties; /** @@ -45,17 +40,9 @@ * @author liuzh */ @Configuration -@ConditionalOnBean(SqlSessionFactory.class) @EnableConfigurationProperties(PageHelperProperties.class) -@AutoConfigureAfter(MybatisAutoConfiguration.class) public class PageHelperAutoConfiguration { - @Autowired - private List sqlSessionFactoryList; - - @Autowired - private PageHelperProperties properties; - /** * 接受分页插件额外的属性 * @@ -67,18 +54,24 @@ public Properties pageHelperProperties() { return new Properties(); } - @PostConstruct - public void addPageInterceptor() { - PageInterceptor interceptor = new PageInterceptor(); - Properties properties = new Properties(); - //先把一般方式配置的属性放进去 - properties.putAll(pageHelperProperties()); - //在把特殊配置放进去,由于close-conn 利用上面方式时,属性名就是 close-conn 而不是 closeConn,所以需要额外的一步 - properties.putAll(this.properties.getProperties()); - interceptor.setProperties(properties); - for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) { - sqlSessionFactory.getConfiguration().addInterceptor(interceptor); - } + @Bean + public ConfigurationCustomizer pageHelperConfigurationCustomizer() { + return new ConfigurationCustomizer() { + @Autowired + private PageHelperProperties properties; + + @Override + public void customize(org.apache.ibatis.session.Configuration configuration) { + PageInterceptor interceptor = new PageInterceptor(); + Properties properties = new Properties(); + //先把一般方式配置的属性放进去 + properties.putAll(pageHelperProperties()); + //在把特殊配置放进去,由于close-conn 利用上面方式时,属性名就是 close-conn 而不是 closeConn,所以需要额外的一步 + properties.putAll(this.properties.getProperties()); + interceptor.setProperties(properties); + configuration.addInterceptor(interceptor); + } + }; } } diff --git a/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-annotation/pom.xml b/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-annotation/pom.xml index 0bcb879..644639d 100644 --- a/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-annotation/pom.xml +++ b/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-annotation/pom.xml @@ -28,7 +28,7 @@ com.github.pagehelper pagehelper-spring-boot-samples - 1.1.1 + 1.2.4-SNAPSHOT pagehelper-spring-boot-sample-annotation jar diff --git a/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-xml/pom.xml b/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-xml/pom.xml index 68e2434..ef88367 100644 --- a/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-xml/pom.xml +++ b/pagehelper-spring-boot-samples/pagehelper-spring-boot-sample-xml/pom.xml @@ -28,7 +28,7 @@ com.github.pagehelper pagehelper-spring-boot-samples - 1.1.1 + 1.2.4-SNAPSHOT pagehelper-spring-boot-sample-xml jar diff --git a/pagehelper-spring-boot-samples/pom.xml b/pagehelper-spring-boot-samples/pom.xml index f42d6b0..6066bc3 100644 --- a/pagehelper-spring-boot-samples/pom.xml +++ b/pagehelper-spring-boot-samples/pom.xml @@ -29,7 +29,7 @@ com.github.pagehelper pagehelper-spring-boot - 1.2.3 + 1.2.4-SNAPSHOT pagehelper-spring-boot-samples pom diff --git a/pagehelper-spring-boot-starter/pom.xml b/pagehelper-spring-boot-starter/pom.xml index 9ade33c..ae880d1 100644 --- a/pagehelper-spring-boot-starter/pom.xml +++ b/pagehelper-spring-boot-starter/pom.xml @@ -29,7 +29,7 @@ com.github.pagehelper pagehelper-spring-boot - 1.2.3 + 1.2.4-SNAPSHOT pagehelper-spring-boot-starter pagehelper-spring-boot-starter diff --git a/pom.xml b/pom.xml index 0a927fc..d28fb56 100644 --- a/pom.xml +++ b/pom.xml @@ -29,7 +29,7 @@ com.github.pagehelper pagehelper-spring-boot - 1.2.3 + 1.2.4-SNAPSHOT pom pagehelper-spring-boot @@ -63,10 +63,10 @@ - 3.4.4 + 3.4.5 5.1.2 1.3.1 - 1.5.7.RELEASE + 1.5.8.RELEASE UTF-8