在Spring中,如果代替下面的示例,而不是仅@EnableWebMvc与@Configurationuse一起使用,将会发生什么@EnableWebMvc?和 @Configuration@Configuration@EnableWebMvcpublic class Clazz { // ..}没有 @Configuration@EnableWebMvcpublic class Clazz { // ..}
1 回答
![?](http://img1.sycdn.imooc.com/54584d6100015f5802200220-100-100.jpg)
明月笑刀无情
TA贡献1828条经验 获得超4个赞
@EnableWebMvc
除非被Spring发现,否则它本身不能做很多事情。Spring搜索标记为的类@Component
。@Configuration
标记为@Component
,因此所有标记为的类@Configuration
都由Spring组件扫描发现,与标记为的类相同@Component
。@EnableWebMvc
标记的类只有在用标记@Component
或带有标记的任何注释时才被发现@Component
添加回答
举报
0/150
提交
取消