您的位置:首页 > 编程语言 > Java开发

<context annotation-config />简介

2017-04-01 14:52 267 查看
该标签隐式的向Spring容器注册了:

AutowiredAnnotationBeanPostProcessor   

CommondAnnotationBeanPostProcessor

PersistenceAnnotationBeanPostProcessor   

RequiredAnnotationBeanPostProcessor

这四个BeanPostProcessor.

1.AutowiredAnnotationBeanPostProcessor:主要是使用@AutoWired注解时,必须提前向Spring容器注册这个BeanPostprocessor

2.CommondAnnotationBeanPostprocessor:主要是使用@Resource、@PostConstruct、@Predestory等注解时,必须提前向Spring容器注册。

3.PersistenceAnnotationBeanPostProcessor :主要是使用@PersistenceContext注解时,必须提前向Spring容器注册。

4.RequiredAnnotationBeanPostProcessor:主要是使用@Required注解时,必须提前向Spring容器注册。

使用注解,一般都会配置扫描包路径:<context: component-scan base-package=com.xxx.xxx />

配置了包扫描之后,<context annotation-config /> 可以移除。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息