SpringMVC配置文件详解:<context:annotation-config/>和<context:component-scan base-package="...
原文地址: https://www.cnblogs.com/lcngu/p/5080702.html Spring配置文件详解:<context:annotation-config/>和<context:component-scan base-package=""/>和<mvc:annotation-driven /> <context: annotation-config/> 在基于主机方式配置Spring时,Spring配置文件applicationContext.xml,你可能会见 <context:annotation-config/> 这样一条配置,它的作用是 隐式的向Spring容器注册 AutowiredAnnotationBeanPostProcessor, CommonAnnotationBeanPostProcessor, PersistenceAnnotationBeanPostProcessor, RequiredAnnotationBeanPostProcessor 这4个 BeanPostProcessor.注册这4个bean处理器主要的作用是 为了你的系统能够识别相应的注解。 例如: 如果想使用 @Autowired 注解,需要在Spring容器中声明 AutowiredAnnotationBeanPostProcessor Bean。传统的声明方式: