初学springmvc,网上下了一个“quickstart”的例子,研究了一下发现在“spring-mvc.xml”中有如下一句话
<!-- 自动扫描且只扫描@Controller -->
<context:component-scan base-package="org.springside.examples.quickstart" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
(这里面我真没看出来是怎么指定只扫描@Controller的。。。。)
而在“applicationContext.xml”中也存在
<!-- 使用annotation 自动注册bean, 并保证@Required、@Autowired的属性被注入 -->
<context:component-scan base-package="org.springside.examples.quickstart">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
两个都是扫描一个包,不会重复么? 还望大家指点下
spring3.X 配置中“<context:component-scan>”组件重复的问题
答案:1 悬赏:80
解决时间 2021-03-06 22:23
- 提问者网友:饮鸿
- 2021-03-06 02:44
最佳答案
- 二级知识专家网友:一池湖水
- 2021-03-06 02:55
context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
这句话 就是器过滤器的作用 只扫描 Controller包下面的类
这句话 就是器过滤器的作用 只扫描 Controller包下面的类
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯