From 3129b573b2942661fe7eaaf6f7a320c0ec9699f5 Mon Sep 17 00:00:00 2001 From: fjn <1194361820@qq.com> Date: Thu, 14 Jan 2021 14:21:04 +0800 Subject: [PATCH] =?UTF-8?q?*=20=E4=BB=A3=E7=A0=81=E6=95=B4=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spring/boot/DynamicDataSourcesAutoConfiguration.java | 4 ++-- .../spring/boot/SpringDataSourcePropertiesAdapter.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/DynamicDataSourcesAutoConfiguration.java b/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/DynamicDataSourcesAutoConfiguration.java index 4ef70f4cc..c993f3325 100644 --- a/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/DynamicDataSourcesAutoConfiguration.java +++ b/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/DynamicDataSourcesAutoConfiguration.java @@ -104,7 +104,7 @@ public DynamicDataSourcesProperties namedDataSourcesProperties(Environment envir @Bean(name = "dataSourcesFactoryBean") public ListFactoryBean dataSourcesFactoryBean( final CentralizedDataSourceFactory centralizedDataSourceFactory, - DynamicDataSourcesProperties namedDataSourcesProperties, + DynamicDataSourcesProperties dynamicDataSourcesProperties, // 该参数只是为了兼容Spring Boot 默认的 DataSource配置而已 ObjectProvider springBootOriginDataSourceProvider, ObjectProvider builtInDataSourceProperties, @@ -123,7 +123,7 @@ public ListFactoryBean dataSourcesFactoryBean( } } - List dataSourcePropertiesList = namedDataSourcesProperties.getDatasources(); + List dataSourcePropertiesList = dynamicDataSourcesProperties.getDatasources(); // spring bean factory final AbstractAutowireCapableBeanFactory beanFactory = ((AbstractAutowireCapableBeanFactory) applicationContext.getAutowireCapableBeanFactory()); diff --git a/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/SpringDataSourcePropertiesAdapter.java b/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/SpringDataSourcePropertiesAdapter.java index c01a7faa6..bf57e49be 100644 --- a/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/SpringDataSourcePropertiesAdapter.java +++ b/sqlhelper-datasource/src/main/java/com/jn/sqlhelper/datasource/spring/boot/SpringDataSourcePropertiesAdapter.java @@ -28,6 +28,7 @@ * @since 3.4.1 */ public class SpringDataSourcePropertiesAdapter { + public static com.jn.sqlhelper.datasource.config.DataSourceProperties adapt(DataSourceProperties properties) { com.jn.sqlhelper.datasource.config.DataSourceProperties dataSourceProperties = new com.jn.sqlhelper.datasource.config.DataSourceProperties(); dataSourceProperties.setUsername(properties.getUsername());