Reputation: 142
I've tried explicitly creating Spring's MessageSource bean in my configuration in the hopes that I could specify a path to the other repo's resource bundle so that I could put all my localization in one place, however i'm not sure what the MessageSource bean would use as a basename. The resources exist in a separate git repo that i'm depending on through maven.
@Bean
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("classpath:/messages");
messageSource.setDefaultEncoding("UTF-8");
messageSource.setUseCodeAsDefaultMessage(true);
return messageSource;
}
}
The default is "classpath:/messages" however in my case, this bean does not reside in the repo that the resource bundle does...Any help is appreciated!
Upvotes: 0
Views: 155
Reputation: 142
The solution for me ended up being move the resource bundle into the new repository and then add it as a maven dependency. In order for this to work I needed to remove the bundle from the resources in the previous place so that the bean that was created locally would no longer prevent the new bean from being used.
From springs docs:
It valid as long as you are defining two bean definitions with same id of same bean on two different spring configuration files. And you are importing one configuration file into another (kind of merging), does not matter how you importing (kind of merging). The later one or the last one bean definition will be override by the first one(s).
Upvotes: 1