Spring Boot Change Value Properties File
1 answer
When it comes to a file messages.properties
, you don't need to dynamically change its contents. You can use variable messages instead. Take a look at this example:
messages.properties:
message=Welcome {0} to my website
If you are handling this message with a MessageSource
bean, you can get this message with
messageSource.getMessage("message", new Object[] { "Test" }, LocaleContextHolder.getLocale())
The returned string in this case:
Welcome Test to my website
Of course, you need to inject MessageSource
into a class (controller, service) before you can use this example code:
@Autowired MessageSource messageSource
+6
source to share