Reputation: 81
In case of supporting both XML and annotation, when spring framework do the annotation scan and how to process it?
Could someone give detail scenario?
For XmlWebApplicationContext, it use loadBeanDefinations() via Xml file. But when it do the annotation scan and use which class to process it?
Could explain the detail for ?
Thanks.
Franklin
Upvotes: 0
Views: 1747
Reputation: 298818
In an XML based Application Context, annotations are only registered if you explicitly configure that:
<!-- register default annotations (e.g. @Required) -->
<context:annotation-config />
<!-- scan for components in selected package -->
<context:component-scan base-package="org.example"/>
Reference:
And if you want to check the inner workings, see:
CommonAnnotationBeanPostProcessor
JavaDoc, Source CodeComponentScanBeanDefinitionParser
JavaDoc, Source CodeUpvotes: 5
Reputation: 5224
I guess u could dig in the sources starting with AnnotationConfigWebApplicationContext.
Upvotes: 0