I am using spring's PropertyPlaceHolderConfigurer as follows :
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath:default.properties</value>
<value>file:${user.home}/webextractor.properties</value>
</list>
</property>
</bean>
Despite having set the ignoreUnresolvablePlaceholders
property to true
, I still get a FileNotFoundException
on /home/kaykay/webextractor.properties
. I know I could just create this file and leave it empty, but I'd like to know what is wrong here.
The ignoreUnresolvablePlaceholders
set to true will ignore placeholders that are not set and not throw an exception.
For example if you have the following property in your class @Value("${person.age}")
and no corresponding value set in your properties file.
The ignoreResourceNotFound
property set to true will have the behavior you expected, that is ignore a resource that isn't found.
Hope this helped.
I have gone through your problem , I think Osiris is right about the property ignoreUnresolvablePlaceholders
. But in case of your , you should to set the property ignoreResourceNotFound
true. So that , if the file is not existing then it will ignore that file.
Modified code will be
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="ignoreResourceNotFound" value="true" />
<property name="locations">
<list>
<value>classpath:default.properties</value>
<value>file:${user.home}/webextractor.properties</value>
</list>
</property>
</bean>
try this code and let me know.
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