Spring <context:annotation-config> 和 <context:component-scan> 区别

一篇很不错的文章,看到就是赚到Get....

      https://www.cnblogs.com/leiOOlei/p/3713989.html

说白了 :<context:component-scan> 包含了 <context:annotation-config> 的作用;

 <context:annotation-config> 就是开启注解的作用,就是来处理@AutoWrized @Resource 注解的,干巴巴的注解放到哪里,是没什么作用的 ,<context:annotation-config> 就是将

这些注解赋予了生命,生命就是我们spring 注册的bean

  注解本身并不能够做任何事情,它们只是最基本的组成部分,我们需要能够处理这些注解的处理工具来处理这些注解。

    这就是<context:annotation-config> 所做的事情

<context:component-scan> 它不仅包含了<context:annotation-config> 的作用,还具有自动将带有@component,@service,@Repository等注解的对象注册到spring容器中的功能。

在开发中,我们常用的就是 <context:component-scan> 了

原创打造,多多指教
原文地址:https://www.cnblogs.com/iscys/p/9610858.html