<context:component-scan/> 配置项不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能,同时还启用了注释驱动自动注入的功能(即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor),因此当使用 <context:component-scan/> 后,就可以将 <context:annotation-config/> 移除了。
<context:component-scan/> 的 base-package 属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理。
<context:component-scan/> 的 base-package 属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理。
<context:component-scan/>配置项不仅启用了类包扫描以实现注释驱动Bean定义的功能,还启用了自动注入功能。该配置项会隐式注册AutowiredAnnotationBeanPostProcessor和CommonAnnotationBeanPostProcessor。通过指定base-package属性,可以确定要扫描的类包范围。
622

被折叠的 条评论
为什么被折叠?



