Deniss M. Deniss M. - 9 days ago 5
Java Question

spring-boot: ResourceBundle with external messages.properties file

@Configuration
public class MessageSourceConfig {

@Bean
public static MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("file: c:/temp/messages");

return messageSource;
}
}


I am trying to make spring-boot to use my external messages.properties, messages_en_Us.properties files. Unfortunately I get this error:

ResourceBundle [file: c:/temp/messages] not found for MessageSource: Can't find bundle for base name file: c:/temp/messages, locale en_US


Files are there and I have studied such cases and it is stated that this should work in spring-boot, but it doesn't. I have also tried
ReloadableResourceBundleMessageSource
and failed the same way. What am I doing wrong here?

Answer

Try that :

    messageSource.setBasename("file://c:/temp/messages");