Spring配置中的<context:annotation-config/>
2014-08-06 10:02
459 查看
今天在配置applicationContext.xml时看到个东西:
<context:annotation-config/>
他的作用是隐式地向 Spring 容器注册
AutowiredAnnotationBeanPostProcessor、
CommonAnnotationBeanPostProcessor、
PersistenceAnnotationBeanPostProcessor、
RequiredAnnotationBeanPostProcessor
这 4 个BeanPostProcessor。
例如:
如果想使用@ Resource 、@ PostConstruct、@ PreDestroy等注解就必须声明CommonAnnotationBeanPostProcessor。
如果想使用@PersistenceContext注解,就必须声明PersistenceAnnotationBeanPostProcessor的Bean。
如果你想使用@Autowired注解,那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。传统声明方式如下:
如果想使用 @Required的注解,就必须声明RequiredAnnotationBeanPostProcessor的Bean。同样,传统的声明方式如下:
<context:annotation-config/>
他的作用是隐式地向 Spring 容器注册
AutowiredAnnotationBeanPostProcessor、
CommonAnnotationBeanPostProcessor、
PersistenceAnnotationBeanPostProcessor、
RequiredAnnotationBeanPostProcessor
这 4 个BeanPostProcessor。
例如:
如果想使用@ Resource 、@ PostConstruct、@ PreDestroy等注解就必须声明CommonAnnotationBeanPostProcessor。
如果想使用@PersistenceContext注解,就必须声明PersistenceAnnotationBeanPostProcessor的Bean。
如果你想使用@Autowired注解,那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。传统声明方式如下:
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor "/>
如果想使用 @Required的注解,就必须声明RequiredAnnotationBeanPostProcessor的Bean。同样,传统的声明方式如下:
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
相关文章推荐
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- Spring配置中的<context:annotation-config/>
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- 关于Spring中的<context:annotation-config/>配置
- 关于使用注解的Spring配置文件的配置<context:annotation-config/>&&<context:component-scan base-package=”XX.XX”/>
- 配置Spring <context:annotation-config/>的作用
- spring <context:annotation-config> 跟 <context:component-scan>诠释及区别
- Spring 配置中<context:annotation-config/> 的作用
- Spring <context:annotation-config/> 解说
- Spring <context:component-scan base-package="">和<context:annotation-config>
- <context:component-scan base-package="">与 <context:annotation-config/>的区别
- Spring配置文件详解一:<:<context:annotation-config/>与<context:component-scan base-package="com.xx
- Spring配置 <context:component-scan/> <mvc:annotation-driven />
- Spring配置项<context:annotation-config/>解释说明
- Spring配置项<context:annotation-config/>解释说明