Inject Service in ConstraintValidator [Bean Validator - JSR 303] Spring

You should set up a LocalValidatorFactoryBean in your Spring application context so you can retrieve Validator (and ValidatorFactory) instances via dependency injection.

By default, a validator obtained like that makes use of SpringConstraintValidatorFactory which provides dependency injection services to constraint validator implementations, as pointed out by Pangea.


Either build a ConstraintValidatorFactory or use SpringConstraintValidatorFactory if you want to wire dependencies.