Thymeleaf doesn't find message source
configuration, spring, thymeleaf
Solution
After a little digging around in the Thymeleaf source code, I found that in the class `SpringTemplateEngine` the Javadoc clearly states:
It also configures a {@link SpringMessageResolver} as message resolver, and implements the {@link MessageSourceAware} interface in order to let Spring automatically setting the {@link MessageSource} used at the application (bean needs to have id "messageSource"). If this Spring standard setting needs to be overridden, the {@link #setTemplateEngineMessageSource(MessageSource)} can be used.
The important part is bean needs to have id "messageSource"
As noted by @ShinichiKai, this part of the Spring documentation mentions that the name of the MessageSource bean in Spring must be `messageSource`.
Problem
I'm actually confused about a part of my Thymeleaf configuration. I have a property file located at `classpath:/messages/web.properties`. In my configuration the following is defined. ``` @Bean public MessageSource messageSource() { final ResourceBundleMessageSource messageSource; messageSource = new ResourceBundleMessageSource(); messageSource.setDefaultEncoding("UTF-8"); messageSource.setBasename("messages/web"); return messageSource; } ``` If I run my application with this configuration everything works fine. The messages from the properties file are injected into the Thymeleaf template (as expected). But if I change the name of the method which creates my message source, restart my application and request the same page... then the messages from my `web.properties` file are not found. ``` @Bean public MessageSource webMessageSource() { [...] } ``` Why the bean name (= method name) of the message resource has this impact to my application? Why the message source `webMessageSource` could not be found by the Thymeleaf template engine?