I added a bean (which is being instantiated and which is used when I @Autowire
it into my classes. But it's not used by bean validation to get the proper messages.
The bean:
@Bean
public MessageSource messageSource()
{
//Create our message source (so we can set directories to use)
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
//Add all our basenames (ours and the custom ones)
messageSource.setBasenames(
"/appbundles/ValidationMessages"
);
return messageSource;
}
In my resources directory, I have:
/resources
/appbundles
ValidationMessages_en_US.properties
When I do it that way, it does not use the messages in that properties directory. If, instead, I move the properties file out to the root of "/resources" then it does work.
How can I make bean validation use the proper basename?