在xml配置了这个标签后,spring可以自动去扫描base-pack下面或者子包下面的java文件,如果扫描到有
@Component
@Controller
@Service
等这些注解的类,则把这些类注册为bean
注意:如果配置了<context:component-scan>那么<context:annotation-config/>标签就可以不用再xml中配置了,因为前者包含了后者。
Spring 自动扫描并注册注解类为bean
本文详细介绍了如何在XML配置中使用<context:component-scan>标签自动扫描并注册带有@Component, @Controller, @Service注解的类为bean。配置此标签后,<context:annotation-config/>不再需要,因为前者包含了后者。
在xml配置了这个标签后,spring可以自动去扫描base-pack下面或者子包下面的java文件,如果扫描到有
@Component
@Controller
@Service
等这些注解的类,则把这些类注册为bean
注意:如果配置了<context:component-scan>那么<context:annotation-config/>标签就可以不用再xml中配置了,因为前者包含了后者。

被折叠的 条评论
为什么被折叠?