1. 程式人生 > >Spring context:component-scan屬性

Spring context:component-scan屬性

<context:component-scan/> 配置項不但啟用了對類包進行掃描以實施註釋驅動 Bean 定義的功能,同時還啟用了註釋驅動自動注入的功能(即還隱式地在內部註冊了 AutowiredAnnotationBeanPostProcessor 和 CommonAnnotationBeanPostProcessor),因此當使用 <context:component-scan/> 後,就可以將 <context:annotation-config/> 移除了。 <context:component-scan/> 的 base-package 屬性指定了需要掃描的類包,類包及其遞迴子包中所有的類都會被處理。