Skip to content
Advertisement

Spring PropertySourcesPlaceholderConfigurer beans: resolve property value at runtime

I am loading properties with multiple PropertySourcesPlaceholderConfigurer beans and setting placeholder prefix-es:

JavaScript

While I can inject a property value by specifying it’s index and key like this:

JavaScript

Sometimes I need to determine the value of the prefix (‘foo’) at runtime and dynamically resolve the property value. Is this possible? If not, which alternative solutions are recommended for this use case?

Advertisement

Answer

Thanks to this post, I’ve found a solution:

JavaScript

Usage:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement