spring component-scan 包扫描

1.配置主容器中Spring不扫描@Controller注解

<!-- spring自动扫描@Component,@Controller,@Service等这些注解的类,则把这些类注册为bean -->
<context:component-scan base-package="com.linktrust.edu">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

2.spring mvc容器中只扫描@Controller注解

<!-- spring自动扫描@Controller注解的类,则把这些类注册为bean -->
<context:component-scan base-package="com.linktrust.edu">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>

exclude-filter 不扫描,include-filter 只扫描

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页