- <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" />
本文详细介绍了Spring框架中<context:annotation-config/>和<context:component-scan/>的作用及用法。前者用于简化@Autowired等注解的配置过程,后者则负责扫描指定包下的类并自动注册Bean。
273

被折叠的 条评论
为什么被折叠?



