spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.51k stars 38.11k forks source link

Capture information about component scanning for subsequent use in diagnostic messages #33022

Open wilkinsona opened 4 months ago

wilkinsona commented 4 months ago

We'd like to improve Spring Boot's failure analysis when refresh fails due to a NoSuchBeanDefinitionException by showing the user some information about component scanning. For example, it could be useful for them to know that com.example.alpha has been scanned when the bean that was not found was in com.example.bravo as it may point towards a misconfiguration of component scanning.

Could Framework record information about the component scanning that's been performed and somehow make it accessible? At the moment, it appears to be an implementation detail of configuration class parsing and there's no way for Boot to get at the information or to intercept the scanning.

snicoll commented 4 months ago

This looks very similar to https://github.com/spring-projects/spring-framework/issues/21604 and I hope we can address both these issues consistently. Andy is sharing that a push model where Spring Boot could register a listener could work.