I have a component scan configuration as this:
@Configuration
@ComponentScan(basePackageClasses = {ITest.class},
includeFilters = {@C
As I said earlier, component scan is working only for concrete classes.
In order to solve my problem I have followed these steps:
org.springframework.context.annotation.ImportBeanDefinitionRegistrar
EnableJdbiRepositories
which is importing my custom importer.Creating a Dummy implementation seems quite hacky to me and all the steps Cemo mentioned require a lot of effort. But extending ClassPathScanningCandidateComponentProvider is the fastest way:
ClassPathScanningCandidateComponentProvider scanningProvider = new ClassPathScanningCandidateComponentProvider(false) {
@Override
protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
return true;
}
};
Now you´re also able to scan for Interfaces with (custom) Annotations with Spring - which also works in Spring Boot fat jar environments, where the fast-classpath-scanner (which is mentioned in this so q&a) could have some limitations.
Instead of scanning an annotated interface, you can create a dummy implementation and annotate it accordingly:
@JdbiRepository
public class DummyTest implements ITest {
public Integer deleteUserSession(String id) {
// nothing here, just being dummy
}
}
Then, scan the dummy implementation basePackageClasses = {DummyTest.class}
.
It's a bit of a workaround, but very simple and good enough for test purposes (as seems to be here).