Deniss M.
Deniss M.

Reputation: 4070

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?

Upvotes: 0

Views: 8418

Answers (1)

davidxxx
davidxxx

Reputation: 131556

Try that :

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

Edit :

After some tests in comments, it is rather this way of doing which works for the OP :

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

Upvotes: 2

Related Questions