【发布时间】:2016-06-21 10:42:14
【问题描述】:
我在 applicationContext.xml 中使用了以下配置
<context:property-placeholder location="classpath:system.properties,file:/data/conf/system.properties,file:/data/conf/1033.properties" ignore-unresolvable="true" />
加载一些占位符:
- 使用
classpath:system.properties中定义的这些属性; - 如果
/data/conf/system.properties中存在文件或属性,请使用它们而不是上面的; - 如果
/data/conf/1033.properties中存在文件或属性,请使用它们而不是上面的。
如果/data/conf/system.properties 和/data/conf/1033.properties 都存在,现在Spring 可以正常启动,但如果它们中的任何一个都不存在,它将抛出rg.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: ...。
如何告诉弹簧加载这些属性,但忽略缺失的。
【问题讨论】:
标签: java spring properties-file property-placeholder