From e5ad4bbb9be3f9049c4e66ec9372e0fc942215dd Mon Sep 17 00:00:00 2001 From: "fusheng.zhang" <17610759700@163.com> Date: Sun, 22 Mar 2020 14:28:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E4=B8=BB=E4=BB=8E?= =?UTF-8?q?=E5=A4=8D=E5=88=B6=20=E6=94=AF=E6=8C=81=E4=B8=80=E4=B8=8B=20cat?= =?UTF-8?q?alog?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../context/spring/SpringDataSourceFactoryDelegate.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/paoding/rose/jade/context/spring/SpringDataSourceFactoryDelegate.java b/src/main/java/net/paoding/rose/jade/context/spring/SpringDataSourceFactoryDelegate.java index fdb7416..a606f3f 100644 --- a/src/main/java/net/paoding/rose/jade/context/spring/SpringDataSourceFactoryDelegate.java +++ b/src/main/java/net/paoding/rose/jade/context/spring/SpringDataSourceFactoryDelegate.java @@ -31,15 +31,18 @@ public class SpringDataSourceFactoryDelegate implements DataSourceFactory { if (dataSourceFactoryMap.containsKey(catalog)) { dataSourceFactory = dataSourceFactoryMap.get(catalog); } else { - String beanName = StringUtils.isEmpty(catalog) ? "jade.dataSourceFactory" : "jade.dataSourceFactory." + catalog; + String beanName = "jade.dataSourceFactory"; + String catlogBeanName = StringUtils.isEmpty(catalog) ? null : beanName + "." + catalog; ListableBeanFactory beanFactory = this.beanFactory; if (beanFactory != null) { - if (beanFactory.containsBeanDefinition(beanName)) { + if (beanFactory.containsBeanDefinition(catlogBeanName)) { + dataSourceFactory = beanFactory.getBean(catlogBeanName, DataSourceFactory.class); + } else if (beanFactory.containsBeanDefinition(beanName)) { dataSourceFactory = beanFactory.getBean(beanName, DataSourceFactory.class); } else { dataSourceFactory = new SpringDataSourceFactory(beanFactory); } - dataSourceFactoryMap.put(beanName, dataSourceFactory); + dataSourceFactoryMap.put(catalog, dataSourceFactory); } } assert dataSourceFactory != null; -- GitLab