com.guanmengyuan.spring.ex.web.config.ValidationConfiguration Maven / Gradle / Ivy
The newest version!
package com.guanmengyuan.spring.ex.web.config;
import jakarta.validation.Validation;
import jakarta.validation.Validator;
import jakarta.validation.ValidatorFactory;
import org.hibernate.validator.HibernateValidator;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.context.annotation.Bean;
@AutoConfiguration
public class ValidationConfiguration {
@Bean
public Validator validator() {
try (ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class).configure().failFast(true).buildValidatorFactory()) {
return validatorFactory.getValidator();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy