BeanCreationException:Injection of autowired dependencies failed
autowired注解引起的问题做个简单的小总结:
-
首先检查 applicationContext.xml里面开启注解扫描器(如果开启继续往下看)
-
注解的值重复了等原因 检查是否多个注解的值重复 导致spring不知道创建哪个bean
-
检查web.xml 扫描applicationContext.xml配置文件的路径是否正确 ,例如:classpath:applicationContext.xml
如果配置文件不在src下 要么改param-value 路径 ,要么把配置文件移到src -
这是个人遇到的错误,BeanCreationException:Injection of autowired dependencies failed 后面还会接着 nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder ‘xxxxx’ in value “${xxxxx}” 的错误,检查发现applicationContext.xml 也导入了外部properties文件,但我是把spring,springmvc的配置文件都整合进的applicationContext.xml里面,复制的时候,出现了两个 <context:property-placeholder location=" "/>标签,网上查找发现 一个xml里面只能识别一个该标签,有两个properties文件 应该用逗号隔开 例如: <context:property-placeholder location=“classpath:crm.properties,classpath:jdbc.properties”/>,而不是分开写两个。