要使用 @Autowired
,需要注册 AutowiredAnnotationBeanPostProcessor
,可以有以下两种方式来实现:
引入配置文件中的<bean>
下引入 <context:annotation-config>
<beans> <context:annotation-config /> </beans>
在bean配置文件中直接引入AutowiredAnnotationBeanPostProcessor
<beans> <bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/> </beans>
标签:装配,配置文件,开启,AutowiredAnnotationBeanPostProcessor,引入,注解 From: https://www.cnblogs.com/wyl010926/p/17744025.html