Below is application.properties file
app.not.found=app with {0} name can not be found.
How to replace {0} with some value in spring?
I am using below code to read properties file values.
env.getProperty("app.not.found")
but not getting how to set placeholder values.
Use MessageFormat.format(String pattern, Object ... arguments)
. It accepts an array in second parameter, which will replace 0, 1 , 2 ... sequentially.
MessageFormat.format(env.getProperty("app.not.found"), obj)
obj will replace {0} in your string.
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