春季-使用不带@Configuration批注的@EnableWebMvc有什么影响?

在Spring中,如果代替下面的示例,而不是仅@EnableWebMvc与@Configurationuse一起使用,将会发生什么@EnableWebMvc?


和 @Configuration


@Configuration

@EnableWebMvc

public class Clazz {

    // ..

}

没有 @Configuration


@EnableWebMvc

public class Clazz {

    // ..

}


慕田峪7331174
浏览 238回答 1
1回答

明月笑刀无情

@EnableWebMvc除非被Spring发现,否则它本身不能做很多事情。Spring搜索标记为的类@Component。@Configuration标记为@Component,因此所有标记为的类@Configuration都由Spring组件扫描发现,与标记为的类相同@Component。@EnableWebMvc标记的类只有在用标记@Component或带有标记的任何注释时才被发现@Component
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java