context:annotation-config 与context:component-scan

<context:annotation-config/>

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

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

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

因此当使用  <context:component-scan/> 后,就可以将 <context:annotation-config/> 移除了。

原文地址:https://www.cnblogs.com/yangy608/p/3330288.html