优化数据源注解查找逻辑,支持目标类和声明类的组合检查

pull/1066/head
qfuzj 2025-07-17 18:09:10 +08:00
parent 725c7dcea2
commit f2a0580c3e
1 changed files with 12 additions and 3 deletions

View File

@ -67,6 +67,15 @@ public class DataSourceAspect
return dataSource;
}
return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class);
}
}
// 组合检查声明类和目标类
Class<?> declaringType = signature.getDeclaringType();
Class<?> targetClass = point.getTarget().getClass();
DataSource classAnnotation = AnnotationUtils.findAnnotation(targetClass, DataSource.class);
if (classAnnotation == null) {
classAnnotation = AnnotationUtils.findAnnotation(declaringType, DataSource.class);
}
return classAnnotation;
}
}