Affects: 5.2.x

I'm trying to create @Repository definitions in a common library / module, and then use them in a separate module with an application defined. I've declared a @ComponentScanner and provided class path entries to the bases for searching. I've also declared @EnableMongoRepositories, with an additional classpath entry to point to the very package that the repositories are in.

The repositories are not being found.

I've traced this to what I believe to be a bug in ClassPathScanningCandidateComponentProvider.isCandidateComponent.

The logic is as follows:

    protected boolean isCandidateComponent(AnnotatedBeanDefinition beanDefinition) {
        AnnotationMetadata metadata = beanDefinition.getMetadata();
        return (metadata.isIndependent() && (metadata.isConcrete() ||
                (metadata.isAbstract() && 
                                  metadata.hasAnnotatedMethods(Lookup.class.getName()))));
    }

Repository definitions are only interfaces (metadata.isAbstract() == true), but their methods are only rarely annotated. In fact, there are enough default methods injected that there will often be no methods explicitly declared. So, metadata.hasAnnotatedMethods will fail.

This is preventing the bean from being loaded and processed, and from being autowired, etc.

Comment From: snicoll

Thanks for the report but rather than a description of what you think might be an issue, we'd need a sample of the actual problem you're experiencing. You can do so by sharing the link of a GitHub repo or attaching a zip to this issue. Thanks

Comment From: jklappenbach

I’ll update the issue this weekend with a demo project on github.

Sent from my iPhone

On May 31, 2020, at 9:59 PM, Stéphane Nicoll notifications@github.com wrote:

 Thanks for the report but rather than a description of what you think might be an issue, we'd need a sample of the actual problem you're experiencing. You can do so by sharing the link of a GitHub repo or attaching a zip to this issue. Thanks

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.