I used the following configuration in my applicationContext.xml
<context:property-placeholder location="classpath:system.properties,file:/data/conf/system.properties,file:/data/conf/1033.properties" ignore-unresolvable="true" />
to load some placeholders:
classpath:system.properties
;/data/conf/system.properties
, use them instead of above;/data/conf/1033.properties
, use them instead of above.Now Spring started ok if both /data/conf/system.properties
and /data/conf/1033.properties
exists, but it will throw rg.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: ...
if either of them does not exist.
How to tell spring load these properties but ignore missing ones.
You have to add ignore-resource-not-found="true"
<context:property-placeholder location="classpath:system.properties,file:/data/conf/system.properties,file:/data/conf/1033.properties"
ignore-unresolvable="true"
ignore-resource-not-found="true"/>