在传统声明方式中
类似这样的注入IOC容器中
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor "/>
1.如果想使用@ Resource 、@ PostConstruct、@ PreDestroy等注解就必须声明CommonAnnotationBeanPostProcessor。
2.如果想使用@PersistenceContext注解,就必须声明PersistenceAnnotationBeanPostProcessor的Bean。
3.如果想使用@Autowired注解,那么就必须事先在 Spring 容器中声明 AutowiredAnnotationBeanPostProcessor Bean。
4.如果想使用 @Required的注解,就必须声明RequiredAnnotationBeanPostProcessor的Bean。
context:annotation-config
而使用context:annotation-config/ 就可以隐式地自动向Spring容器注册4个BeanPostProcessor:
AutowiredAnnotationBeanPostProcessor
CommonAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor
RequiredAnnotationBeanPostProcessor
这样就可以使用@ Resource 、@ PostConstruct、@ PreDestroy、@PersistenceContext