Spring framework: No message found under code for locale
For spring boot you need something like this:
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasename("/WEB-INF/classes/messages");
return messageSource;
}
In general such issue appears not because of non-existence locale, but because MessageBundle
is configured improperly. In your case you seem to need to remove "/" in your basename.
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
p:basename="/WEB-INF/messages" />
Why it is so:
If you have messages.properties
and messages_en.properties
bundle, then bundle name is messages
. If you have them in the WEB-INF
folder, then basename is /WEB-INF/messages
, i.e. according to /path/to/bundle/bundlename
. If you have messages.properties
within /WEB-INF/messages
folder, then corresponding basename is /WEB-INF/messages/messages
.