spring配置中context:annotation-config 与 context:component-scan 区别
1)context:annotation-config可以理解为注解解析器,解析诸如@autowired,@Resource之类的注解。前提是注解作用的类已经被注册到spring容器里。
2)context:component-scan除了包含context:annotation-config所有的功能之外还可以自动扫描和注册base-package下有诸如@component之类注解的类,并将其作为bean注册到spring容器里。
总结:有component-scan就不需要annotation-config了。