除去properites文件路径错误、拼写错误外,出现"Could not resolve placeholder"颇有多是使用了多个PropertyPlaceholderConfigurer或者多个<context:property-placeholder>的缘由。web
好比我有一个dao.xml读取dbConnect.properties,还有一个dfs.xml读取dfsManager.properties,而后web.xml统一load这两个xml文件spring
若是这两个xml文件中分别有spa
那么,必定会出"Could not resolve placeholder"。xml
必定要记住,无论是在一个Spring文件仍是在多个Spring文件被统一load的状况下,直接写blog
是不容许的。get
解决方案:it
(1) 在Spring 3.0中,能够写:io
注意两个都要加上ignore-unresolvable="true",一个加另外一个不加也是不行的class
(2) 在Spring 2.5中,<context:property-placeholder>没有ignore-unresolvable属性,此时能够改用PropertyPlaceholderConfigurer。其实<context:property-placeholder location="xxx.properties" ignore-unresolvable="true" />与下面的配置是等价的配置
正由于如此,写多个PropertyPlaceholderConfigurer不加ignoreUnresolvablePlaceholders属性也是同样会出"Could not resolve placeholder"。
虽然二者是的等价的,但估计你们仍是喜欢写<context:property-placeholder>多一些,毕竟简单一些嘛。因此若是是Spring 3.0,直接用解决方案(1)再简单不过了;若是是Spring 2.5,须要费点力气改写成PropertyPlaceholderConfigurer