Spring配置之context:annotation与、component-scan以及annotation-driven

 spring boot帮助我们隐藏了大量的细节,有些配置spring boot都是开启的,因此当我们查看遗留项目使用spring时候遇见问题一定细心排查

   <!-- context:annotation 注解作用是:对于项目中使用注解的变量,而且该变量的值在spring容器中存在的话,则就将值注入到变量中-->
    <context:annotation-config/>
    <!--context:component-scan除了有annotation-config作用外,还有扫描组件到容器中的功能 -->
    <context:component-scan base-package="com.daxin"/>
    <!-- mvc:annotation-driven会自动注册RequestMappingHandlerMapping与RequestMappingHandlerAdapter两个Bean,这是Spring MVC为@Controller分发请求所必需的,并且提供了数据绑定支持 -->
    <mvc:annotation-driven/>

  

原文地址:https://www.cnblogs.com/leodaxin/p/8659866.html