How to set placeholder values in properties file in spring
问题 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. 回答1: 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