annotation-config處理@autowired之類的注解(共有四類) 前提是注解作用的類已經被注冊到spring容器里(bean id=“” class=“”)
component-scan除了包含annotation-config的作用外,還能自動掃描和注冊base-package下有@component之類注解的類,將其作為bean注冊到spring容器里
所以配置文件如果有component-scan就不需要annotation-config了。
annotation-config處理@autowired之類的注解(共有四類) 前提是注解作用的類已經被注冊到spring容器里(bean id=“” class=“”)
component-scan除了包含annotation-config的作用外,還能自動掃描和注冊base-package下有@component之類注解的類,將其作為bean注冊到spring容器里
所以配置文件如果有component-scan就不需要annotation-config了。
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。