作用:提供依赖注入的功能
该标签隐式的向Spring容器注册了
四个BeanPostProcessor.:
AutowiredAnnotationBeanPostProcessor
AutowiredAnnotationBeanPostProcessor
CommondAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor
RequiredAnnotationBeanPostProcessor
1.AutowiredAnnotationBeanPostProcessor---@AutoWired注解
传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
2.CommondAnnotationBeanPostprocessor---@Resource、@PostConstruct、@Predestory等注解
传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
3.PersistenceAnnotationBeanPostProcessor ---@PersistenceContext注解
传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
4.RequiredAnnotationBeanPostProcessor---@Required注解
传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
注意:
不过使用注解,我们一般都会配置扫描包路径:<context: component-scan base-package=com.xxx.xxx />
其实,给配置已经包含了自动注入上述Processor的功能,所以,配置了包扫描之后,<context annotation-config />就可以移除了。
不过使用注解,我们一般都会配置扫描包路径:<context: component-scan base-package=com.xxx.xxx />
其实,给配置已经包含了自动注入上述Processor的功能,所以,配置了包扫描之后,<context annotation-config />就可以移除了。