spring引入多个properties文件

来源:互联网 发布:淘宝免费引流 编辑:程序博客网 时间:2024/05/21 06:24
在开发中常常把配置信息放在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文件,用英文逗号隔开。
0 0
原创粉丝点击