From a38ed705f5a31ddc99cf0c8a499d82e0aa885e54 Mon Sep 17 00:00:00 2001 From: RuoYi Date: Tue, 19 May 2020 11:05:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE=E6=BA=90?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BC=98=E5=85=88=E7=BA=A7=EF=BC=8C=E5=85=88?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=96=B9=E6=B3=95=EF=BC=8C=E5=86=8D=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/ruoyi/common/annotation/DataSource.java | 4 ++-- .../java/com/ruoyi/framework/aspectj/DataSourceAspect.java | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java index bba1c059..6b41ee73 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java @@ -11,8 +11,8 @@ import com.ruoyi.common.enums.DataSourceType; /** * 自定义多数据源切换注解 * - * 优先级: 先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 - * + * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 + * * @author ruoyi */ @Target({ ElementType.METHOD, ElementType.TYPE }) 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 cb516460..f72b8051 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 @@ -1,6 +1,5 @@ package com.ruoyi.framework.aspectj; -import java.lang.reflect.Method; import java.util.Objects; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; @@ -18,7 +17,7 @@ import com.ruoyi.common.utils.StringUtils; /** * 多数据源处理 - * + * * @author ruoyi */ @Aspect @@ -62,8 +61,6 @@ public class DataSourceAspect public DataSource getDataSource(ProceedingJoinPoint point) { MethodSignature signature = (MethodSignature) point.getSignature(); - // point.getTarget().getClass(); 这个获取的是动态代理的class,上面获取不到自定义注解 - // 先获取方法上的,获取不到啊再从class上找 DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class); if (Objects.nonNull(dataSource)) {