一、自动扫描

使用Annotation自动注册Bean:在主容器中不扫描@Controller注解,在SpringMvc中只扫描@Controller注解。

  1、spring配置文件(扫描注解)

<context:component-scan base-package="com.*.*"><!-- base-package 如果多个,用“,”分隔 -->
    <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

   2、springmvc配置文件(扫描注解)

<context:component-scan base-package="com.*.*"><!-- base-package 如果多个,用“,”分隔 -->
    <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
</context:component-scan>

 

  

posted on 2016-07-29 09:52  逝水往昔拂流年  阅读(141)  评论(0编辑  收藏  举报