mirror of
https://github.com/hs-web/hsweb-framework.git
synced 2026-06-04 11:52:41 +08:00
refactor: 优化配置
This commit is contained in:
@@ -31,7 +31,7 @@ import static org.hswebframework.web.datasource.strategy.AnnotationDataSourceSwi
|
||||
* @author zhouhao
|
||||
* @since 3.0
|
||||
*/
|
||||
@Configuration
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class AopDataSourceSwitcherAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package org.hswebframework.web.datasource;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author zhouhao
|
||||
@@ -22,24 +18,5 @@ public class DynamicDataSourceAutoConfiguration {
|
||||
return new HswebDataSourceProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BeanPostProcessor switcherInitProcessor() {
|
||||
return new BeanPostProcessor() {
|
||||
@Override
|
||||
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
|
||||
if (bean instanceof DynamicDataSourceService) {
|
||||
DataSourceHolder.dynamicDataSourceService = ((DynamicDataSourceService) bean);
|
||||
}
|
||||
|
||||
return bean;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user