【发布时间】:2016-12-16 18:14:46
【问题描述】:
在我们的 WebApplication 类中,我想找到所有用@Configuration 注释的类。
我正在使用下面的代码来做到这一点:
ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(Configuration.class));
Set<BeanDefinition> configurationBeans = scanner.findCandidateComponents("com.company");
但是findCandidateComponents 不会返回同时使用@Configuration 和@ConditionalOnWebApplication 注释的类。
我将过滤器更改为以下,只是为了测试:
scanner.addIncludeFilter(new `AnnotationTypeFilter(ConditionalOnWebApplication.class));`
我没有上课。
如何解决?
【问题讨论】:
标签: java spring reflection annotations