In my Spring Boot app I have a backing bean where I am using JSR303 validation. In the annotation, I have specified the message code:
@NotBlank(message = \"
According to JSR-303 specification message parameters are expected to be stored in ValidationMessages.properties
files. But you can override the place where they are looked for.
So you have 2 options:
ValidationMessages.properties
fileOr override getValidator()
method of your WebMvcConfigurerAdapter
's descendant (JavaConfig
in your case):
@Override
public Validator getValidator() {
LocalValidatorFactoryBean validator = new LocalValidatorFactoryBean();
validator.setValidationMessageSource(messageSource());
return validator;
}