How to I get Spring-Data-MongoDB to validate my objects?

First make sure that you have JSR-303 validator on classpath, for example:


If you use Java config, the way to go is to create 2 beans:

public ValidatingMongoEventListener validatingMongoEventListener() {
    return new ValidatingMongoEventListener(validator());

public LocalValidatorFactoryBean validator() {
    return new LocalValidatorFactoryBean();

VoilĂ ! Validation is working now.

Leave a Comment