I have message property files in my Spring web application. The following is a related configuration:
@Bean
public MessageSource messageSource() {
ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
messageSource.setBasenames("classpath:messages");
messageSource.setUseCodeAsDefaultMessage(true);
messageSource.setDefaultEncoding("UTF-8");
messageSource.setCacheSeconds(0);
return messageSource;
}
The message in the property doesn't show up but the key with a language suffix. For example, a key, nav.welcome, in the property file is shown on a web page as ??nav.welcome_en?? I use Gradlew to run my application. And I see the messages.properties file on the root of the class path.
C:\Users\vic\workspace-sts\myapp\build\tmp\tomcatRunWar\work\Tomcat\localhost\_\WEB-INF\classes>
After turning up org.springframework.web log level, I see the following related log messages:
DEBUG: AnnotationConfigWebApplicationContext:649 - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@2a83e48a]
and
DEBUG: AnnotationConfigWebApplicationContext:639 - Using MessageSource [org.springframework.context.support.ResourceBundleMessageSource: basenames=[classpath:messages]]
What is missing here?