I'd like to use the ClassPathScanningCandidateComponentProvider
for searching different subclasses of one class. But I need to exclude a special directory in this case.
Example:
Directories/Packages:
src/main/java/frstPck/scndPck
src/test/java/frstPck/scndPck
Code for scanning:
public static void example() throws ClassNotFoundException {
ClassPathScanningCandidateComponentProvider provider = new ClassPathScanningCandidateComponentProvider(false);
provider.addIncludeFilter(new AssignableTypeFilter(Super.class));
Set<BeanDefinition> components = provider.findCandidateComponents("frstPck/scndPck");
for (BeanDefinition component : components) {
Class<?> cls = Class.forName(component.getBeanClassName());
System.out.print(cls.getSimpleName());
}
}
The problem is, that the classpathscanning would also find subclasses of src/test/java
and exactly this should not happen. Is there any possibility to exclude those?