I load a properties file in spring :
<context:property-placeholder location="classpath:foo.properties"/>
But if I try to load another file in a different context file I get error.
According to the sources you must provide comma separated list of propery files resources. This should work for you:
<context:property-placeholder location="classpath:foo1.properties,classpath:foo2.properties"/>
if you need to override properties you can do:
<context:property-override location="classpath:override.properties"/>
OR
if the error is due to not finding a certain property, you can set ignoreUnresolvablePlaceholders to true.
OR
if the error is about not found resource ( and you're ok with it ), you can set ignoreResourceNotFound to true.
OR
if there are errors in finding system properties:
The PropertyPlaceholderConfigurer not only looks for properties in the Properties file you specify. By default it also checks against the Java System properties if it cannot find a property in the specified properties files. You can customize this behavior by setting the systemPropertiesMode property of the configurer with one of the following three supported integer values:
never (0): Never check system properties
fallback (1): Check system properties if not resolvable in the specified properties files. This is the default.
override (2): Check system properties first, before trying the specified properties files. This allows system properties to override any other property source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With