From 82da979c27680eefe1c7cd92efd7033f1ea685f9 Mon Sep 17 00:00:00 2001 From: crossoverJie Date: Thu, 5 Jan 2017 02:06:15 +0800 Subject: [PATCH] update --- .../com/crossoverJie/util/DataSourceExchange.java | 12 ++++++++++-- .../com/crossoverJie/util/DynamicDataSource.java | 2 -- src/main/resources/redis.properties | 4 ++-- src/main/resources/spring-mybatis.xml | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/crossoverJie/util/DataSourceExchange.java b/src/main/java/com/crossoverJie/util/DataSourceExchange.java index 724b098..97eef52 100644 --- a/src/main/java/com/crossoverJie/util/DataSourceExchange.java +++ b/src/main/java/com/crossoverJie/util/DataSourceExchange.java @@ -3,7 +3,7 @@ import org.aspectj.lang.JoinPoint; /** - * Function: + * Function:拦截器方法 * * @author chenjiec * Date: 2017/1/3 上午12:34 @@ -11,10 +11,15 @@ */ public class DataSourceExchange { - + /** + * @param point + */ public void before(JoinPoint point) { + //获取目标对象的类类型 Class aClass = point.getTarget().getClass(); + + //获取包名用于区分不同数据源 String whichDataSource = aClass.getName().substring(25, aClass.getName().lastIndexOf(".")); if ("ssmone".equals(whichDataSource)) { DataSourceHolder.setDataSources(Constants.DATASOURCE_ONE); @@ -25,6 +30,9 @@ public void before(JoinPoint point) { } + /** + * 执行后将数据源置为空 + */ public void after() { DataSourceHolder.setDataSources(null); } diff --git a/src/main/java/com/crossoverJie/util/DynamicDataSource.java b/src/main/java/com/crossoverJie/util/DynamicDataSource.java index 4c48b86..edd0917 100644 --- a/src/main/java/com/crossoverJie/util/DynamicDataSource.java +++ b/src/main/java/com/crossoverJie/util/DynamicDataSource.java @@ -10,8 +10,6 @@ * @since JDK 1.7 */ public class DynamicDataSource extends AbstractRoutingDataSource { - - @Override protected Object determineCurrentLookupKey() { return DataSourceHolder.getDataSources(); diff --git a/src/main/resources/redis.properties b/src/main/resources/redis.properties index c1cd735..25dd5b8 100644 --- a/src/main/resources/redis.properties +++ b/src/main/resources/redis.properties @@ -1,7 +1,7 @@ #redis中心 -redis.host=27.126.180.210 +redis.host=127.0.0.1 redis.port=6379 -redis.password=tiger +redis.password=xxx redis.maxIdle=100 redis.maxActive=300 redis.maxWait=1000 diff --git a/src/main/resources/spring-mybatis.xml b/src/main/resources/spring-mybatis.xml index beefe73..3343ac5 100644 --- a/src/main/resources/spring-mybatis.xml +++ b/src/main/resources/spring-mybatis.xml @@ -223,6 +223,7 @@ +