Giriş
Şu satırı dahil ederiz
Örnekimport org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;
Şöyle yaparız
import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider;import org.springframework.core.type.filter.AnnotationTypeFilter;ClassPathScanningCandidateComponentProvider scanner = new ClassPathScanningCandidateComponentProvider(false);scanner.addIncludeFilter(new AnnotationTypeFilter(FooAnnotation.class));Set<BeanDefinition> beanDefinitions = scanner.findCandidateComponents("com.foo");if (!CollectionUtils.isEmpty(beanDefinitions)) {for (final BeanDefinition beanDefinition : beanDefinitions) {Class<?> fooClass = Class.forName(beanDefinition.getBeanClassName());...}}
Hiç yorum yok:
Yorum Gönder