From eca1c2ce8506dfd5ad8f94235382b666ea831dfd Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期六, 08 二月 2025 17:58:19 +0800 Subject: [PATCH] 动态切换数据库实现 --- ltkj-framework/src/main/java/com/ltkj/framework/interceptor/DBChangeInterceptor.java | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ltkj-framework/src/main/java/com/ltkj/framework/interceptor/DBChangeInterceptor.java b/ltkj-framework/src/main/java/com/ltkj/framework/interceptor/DBChangeInterceptor.java index a049f69..083f6a3 100644 --- a/ltkj-framework/src/main/java/com/ltkj/framework/interceptor/DBChangeInterceptor.java +++ b/ltkj-framework/src/main/java/com/ltkj/framework/interceptor/DBChangeInterceptor.java @@ -29,10 +29,10 @@ @Autowired private IDictHospService dictHospService; -// @Autowired -// private DataSourceConfig dataSourceConfig; @Autowired - private DruidConfig druidConfig; + private DataSourceConfig dataSourceConfig; +// @Autowired +// private DruidConfig druidConfig; @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException { @@ -55,8 +55,8 @@ response.getWriter().write("{\"message\":\"401锛氭壘涓嶅埌闄㈠尯鏁版嵁\"}"); return false; } -// dataSourceConfig.addDataSource(hosp.getDbname()); - druidConfig.addDataSource(hosp.getDbname()); + dataSourceConfig.addDataSource(hosp.getDbname()); +// druidConfig.addDataSource(hosp.getDbname()); DataSourceContextHolder.setDataSourceKey(hosp.getDbname()); } catch (IOException e) { return false; -- Gitblit v1.8.0