<context:component-scan/> 配置项不但启用了对类包进行扫描以实施注释驱动 Bean 定义的功能,同时还启用了注释驱动自动注入的功能(即还隐式地在内部注册了 AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor),因此当使用 <context:component-scan/> 后,就可以将 <context:annotation-config/> 移除了。 <context:component-scan/>
的 base-package 属性指定了需要扫描的类包,类包及其递归子包中所有的类都会被处理。
Spring context:component-scan属性
最新推荐文章于 2021-03-04 15:22:38 发布
本文详细解析了Spring框架中<context:component-scan/>配置项的作用,不仅启用了类包扫描以实现注解驱动的Bean定义功能,还隐式启用了@Autowired和@Common注解的自动注入功能,简化了<context:annotation-config/>的使用。
634

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



