在开发中常常把配置信息放在properties文件中,然后spring的xml中引入。如果在多个spring的xml文件中引入properties
<context:property-placeholder ignore-unresolvable="true" location="classpath:config/wzk.properties" />
spring启动会报错:
org.springframework.beans.factory.BeanDefinitionStoreException: Invalid bean definitionwith name
Causedby: java.lang.IllegalArgumentException: Couldnot resolve placeholder
即找不到某个配置项。
原来spring只允许有一个<context:property-placeholder/>
可以这样解决
<context:property-placeholder ignore-unresolvable="true" location="classpath:config/wzk.properties,classpath:config/mongodb.properties" />
即在一个<context:property-placeholder/>中引入多个.properties文件,用英文逗号隔开。