context:annotation-config 与context:component-scan

<context:annotation-config/>spa

<context:component-scan base-package="com.xx" />component

<context:component-scan/>不但启用了对类包进行扫描以实施注释驱动
Bean 定义的功能,同时还启用了注释驱动自动注入的功能io

(即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessor CommonAnnotationBeanPostProcessor,<context:annotation-config/>的功能),sso

所以当使用  <context:component-scan/> 后,就能够将 <context:annotation-config/> 移除了。
注释

相关文章
相关标签/搜索