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/> 移除了。

posted @ 2013-09-20 11:38  七郎  Views(475)  Comments(0Edit  收藏  举报