From 316b126c8f4e81ea43c1549462a4d838178149c8 Mon Sep 17 00:00:00 2001 From: dhx920 Date: Mon, 18 Mar 2019 11:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3DynamicDataSourceContextHolde?= =?UTF-8?q?r=E7=B1=BB=E4=B8=AD=E4=B8=89=E5=A4=84DataSource=E6=8B=BC?= =?UTF-8?q?=E5=86=99=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/datasource/DynamicDataSourceContextHolder.java | 6 +++--- .../java/com/ruoyi/framework/aspectj/DataSourceAspect.java | 4 ++-- .../com/ruoyi/framework/datasource/DynamicDataSource.java | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java index 968a9692c..6bc9e6178 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/datasource/DynamicDataSourceContextHolder.java @@ -21,7 +21,7 @@ public class DynamicDataSourceContextHolder /** * 设置数据源的变量 */ - public static void setDateSoureType(String dsType) + public static void setDataSourceType(String dsType) { log.info("切换到{}数据源", dsType); CONTEXT_HOLDER.set(dsType); @@ -30,7 +30,7 @@ public class DynamicDataSourceContextHolder /** * 获得数据源的变量 */ - public static String getDateSoureType() + public static String getDataSourceType() { return CONTEXT_HOLDER.get(); } @@ -38,7 +38,7 @@ public class DynamicDataSourceContextHolder /** * 清空数据源变量 */ - public static void clearDateSoureType() + public static void clearDataSourceType() { CONTEXT_HOLDER.remove(); } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java index 277176800..89d28facf 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java @@ -43,7 +43,7 @@ public class DataSourceAspect if (StringUtils.isNotNull(dataSource)) { - DynamicDataSourceContextHolder.setDateSoureType(dataSource.value().name()); + DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); } try @@ -53,7 +53,7 @@ public class DataSourceAspect finally { // 销毁数据源 在执行方法之后 - DynamicDataSourceContextHolder.clearDateSoureType(); + DynamicDataSourceContextHolder.clearDataSourceType(); } } } diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java index 675a335e9..a5f764072 100644 --- a/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java @@ -22,6 +22,6 @@ public class DynamicDataSource extends AbstractRoutingDataSource @Override protected Object determineCurrentLookupKey() { - return DynamicDataSourceContextHolder.getDateSoureType(); + return DynamicDataSourceContextHolder.getDataSourceType(); } } \ No newline at end of file