组件扫描配置

有时候我们并不需要扫描包下所有的注解,即有时我们只需要扫描特定的注解时,我们可以自己组件扫描配置。

  1. 首先关闭默认的过滤器。
<context:component-scan base-package="包路径" use-default-filters="false">
  1. 然后指定要扫描的注解。
    <context:include-filter 
             type="annotation"                           		            			 expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
posted @ 2023-06-08 14:18  郭培鑫同学  阅读(12)  评论(0编辑  收藏  举报