I have legacy spring(not boot) application and I want to get all classes marked with specific annotation. To acchieve it I use following answer: https://stackoverflow.com/a/1415338/2674303
So I've created following class:
@Component
public class MyVerifier {
public void verify() {
ClassPathScanningCandidateComponentProvider scanner =
new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(MyNotification.class));
Set<BeanDefinition> set = scanner.findCandidateComponents("base.pack")
}
In code I have:
@MyNotification
public class MyClass...
@MyNotification
public class MyOtherClass...
But set
variable is empty set. Why ?
How to fix it ?
Aucun commentaire:
Enregistrer un commentaire