diff --git a/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/DynamicRoutingDataSource.java b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/DynamicRoutingDataSource.java index e4b6c7d0..d1b877d4 100644 --- a/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/DynamicRoutingDataSource.java +++ b/dynamic-datasource-spring/src/main/java/com/baomidou/dynamic/datasource/DynamicRoutingDataSource.java @@ -194,7 +194,6 @@ public synchronized void removeDataSource(String ds) { } if (dataSourceMap.containsKey(ds)) { DataSource dataSource = dataSourceMap.remove(ds); - closeDataSource(ds, dataSource, graceDestroy); if (ds.contains(UNDERLINE)) { String group = ds.split(UNDERLINE)[0]; if (groupDataSources.containsKey(group)) { @@ -204,6 +203,7 @@ public synchronized void removeDataSource(String ds) { } } } + closeDataSource(ds, dataSource, graceDestroy); log.info("dynamic-datasource - remove the database named [{}] success", ds); } else { log.warn("dynamic-datasource - could not find a database named [{}]", ds);