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删除。