In my Spring Boot application I am getting the message: org.springframework.context.NoSuchMessageException: No message found under code 'invalidAdminPassword' for locale 'en_GB'.
I know this is due to the MessageSource
object which in my code is defined as:
@Bean
public ReloadableResourceBundleMessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
Locale.setDefault(Locale.UK);
messageSource.setBasename("messages_en_GB");
messageSource.setCacheSeconds(3600); // Refresh cache once per hour.
return messageSource;
}
In messages_en_GB.properties
, I have message:
# Other validation messages.
invalidAdminPassword=Invalid password.
And in the controller concerned I have:
System.out.println(messageSource.getMessage("invalidAdminPassword", null, Locale.UK));
Just to test the retrieval from the messages_en_GB.properties
file.
I believe that I am using Spring Boot default settings so why do I get the message org.springframework.context.NoSuchMessageException: No message found under code 'invalidAdminPassword' for locale 'en_GB'.
?
Can anyone advise?
tl;dr: there is a minimal running example in the link.
To solve your problem, please answer, please give some more details:
a) Where have you put your messages.properties?
b) Are there more than one messages{.*}.properties?