@FeignClient 不是有一些如 name 、url 等的属性信息么
通过applicationContext.getBeansWithAnnotation(FeignClient.class)
可以拿到 @FeignClient 的所有 bean
但是由于 @FeignClient 都是 interface,通过getAnnotations()
拿不到注解的属性信息,
代码如下,求大神指点一下
Map<String,Object> beans = applicationContext.getBeansWithAnnotation(FeignClient.class);
if (beans.size() > 0){
for (Map.Entry<String, Object> entry : beans.entrySet()){
String beanName = entry.getKey();
Annotation[] annotations = entry.getValue().getClass().getAnnotations(); //空的
AnnotatedType[] annotatedTypes = entry.getValue().getClass().getAnnotatedInterfaces();
for(AnnotatedType annotationType : annotatedTypes){
Type type = annotationType.getType();
Annotation[] typeAnnotations = type.getClass().getAnnotations(); //空的
Annotation[] annotationTypeAnnotations = annotationType.getAnnotations(); //空的
Annotation[] declaredAnnotations = annotationType.getDeclaredAnnotations(); //空的
System.out.println(annotationTypeAnnotations);
System.out.println(declaredAnnotations);
}
}
}
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.