- <context:annotation-config/>
-
如果想使用@Autowired注解,需要在Spring容器中声明AutowiredAnnotationBeanP ostProcessor Bean。传统的声明方式:<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanP ostProcessor"/> - 如果想使用@PersistenceContext注解,需要在Spring容器中声明PersistenceAnnotationBea
nPostProcessor Bean。传统的声明:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPo stProcessor"/> - 如果想使用@Required注解,需要在Spring容器中声明RequiredAnnotationBeanPo
stProcessor Bean。传统声明方式: <bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPo stProcessor"/> - 如果想使用@Resource、@ PostConstruct、@ PreDestroy等注解就必须声明CommonAnnotationBeanPost
Processor。传统申明方式: <bean class="org.springframework.beans.factory.annotation.CommonAnnotationBeanPost Processor"/>
因此如果在Spring的配置文件中事先加上 <context:annotation-config/>这样一条配置的话,那么所有注解的传统声明就可以被
-
<context:component-scan base-package="com.xx" />