0

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?

Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
  • have you tried specifying the full path? resources/appbundles/ValidationMessages_en_US.properties? Under the root, it's automatically being taken as a properties container! And also please rectify the parameter you set in the setBasenames method. – sbsatter Nov 03 '17 at 18:17
  • @sbs How would that work? In a jar, does it still have the resources directory? I thought that wasn't put into the jar? – Don Rhummy Nov 03 '17 at 18:20

0 Answers0