Spring - context:annotation-config 与 context:component-scan 的区别与使用
<context:annotation-config> is used to activate annotations in beans already registered in the application context (no matter if they were defined with XML or by package scanning <context:component-scan> can also activate annotations in beans but also scans packages to find and register beans within the application context. To use annotations like @Required, @Autowired etc you need at least <context:annotation-config> that is because "annotations are a nice feature but by themselves they do nothing whatsoever. They just annotate stuff. You need a processing tool to find the annotations and do something with them. <context:annotation-config> to the rescue. This activates the actions for the annotations that it finds on the beans defined in the same application context where itself is defined." But since <context:annotation-config> only works with beans that has already been registered. If we don't manually register those beans in ...