I have a question related to how Spring handles multiple property-placeholder.
I have this section of code:
<context:property-placeholder location="classpath:dir1/${myapp.system.property}.properties"/>
The property myapp.system.property is a defined System property.
If it is defined to "devsystem", for example, all the properties defined in devsystem.properties are imported and are available to use in the code below.
Now I wanted to have another property file whose name is defined by a properties in the devsystem.property file:
<context:property-placeholder location="classpath:dir1/${myapp.system.property}.properties"/>
<context:property-placeholder location="classpath:dir2/myapp-${myapp.environment}.properties"/>
myapp.environment is a property defined in the devsystem.properties file.
This stopped working. Spring cannot resolve ${myapp.environment} and complains it cannot locate file dir2/myapp-${myapp.environment}.properties.
Can someone let me know what I did wrong and how can I make this working?
You can do something like this
<context:property-placeholder location="classpath:file1.properties,classpath*:project-common.properties,classpath*:project-${spring.profiles.active}.properties"/>
In my case, it was a legacy system so property files didn't have some standard names but for sure you can use wildcards to reference your property files.
<context:property-placeholder location="classpath:*.properties"/>
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