Reputation: 670
I am currently using the following code which is working correctly:
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB-INF/resources/lang/lang</value>
</list>
</property>
<property name="defaultEncoding" value="UTF-8"/>
</bean>
When I change ReloadableResourceBundleMessageSource to just ResourceBundleMessageSource it stops working.
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/resources/lang/lang" />
</bean>
I keep getting exceptions saying "No message found under code 'title' for locale 'en_US'." (title is an example)
After reading similar questions, I have also tried changing the value of basename parameter to any of the following, without success:
WEB-INF/resources/lang/lang
.WEB-INF.resources.lang.lang
WEB-INF.resources.lang.lang
resources.lang.lang
lang.lang
lang
classpath:resources.lang.lang
Making a file called lang_en_US.properties didn't help either.
Upvotes: 0
Views: 1025
Reputation: 670
Apparently, it is looking in the java folder (root of classpath) and not the web folder.
I created a new package called lang in the java folder and moved the lang*.properties files to it.
Then I put lang.lang as the value for basename and it started to work.
UPDATE: This stopped working after a project clean. The lang files should go into the "resources" folder, not the java folder. They technically end up in the same place after a build, but the IDE seems to ignore non-class files in the java folder and simply skips them.
Upvotes: 1