spring中<context:annotation-config/>配置的作用,现记录如下:

<context:annotation-config/>的作用是向Spring容器注册以下四个BeanPostProcessor:

  • AutowiredAnnotationBeanPostProcessor
  • CommonAnnotationBeanPostProcessor
  • PersistenceAnnotationBeanPostProcessor
  • RequiredAnnotationBeanPostProcessor

那么,为什么要注册这四个BeanPostProcessor呢?是为了让系统能够识别相应的注解。 例如:

注:

05-11 16:53