Reputation: 107
I was thinking using reflection, spring scanning all the classes and it's annotations, method. But I heard using reflection can't get class details with package name. Then how spring scan classes under specified package?
Upvotes: 1
Views: 641
Reputation: 1367
Honestly, I do not remember everything in detail, but if I'm not mistaken component-scan processed by ComponentScanBeanDefinitionParser.class. It is looking for all base packages and scan them for beanDefinitions.
Scanning performs ClassPathBeanDefinitionScanner.class, it finds all candidates for beanDefinitions using their metadata.
Search for candidates in base package performs ClassPathScanningCandidateComponentProvider.class with ResourcePatternResolver.class.
Try to find out how exactly this mechanism works with debugger. Hope this info helps you.
Upvotes: 1