You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
775 B
24 lines
775 B
package cc.bnblogs.annotations.config; |
|
|
|
import org.hibernate.validator.HibernateValidator; |
|
import org.springframework.context.annotation.Bean; |
|
import org.springframework.context.annotation.Configuration; |
|
|
|
import javax.validation.Validation; |
|
import javax.validation.Validator; |
|
import javax.validation.ValidatorFactory; |
|
|
|
@Configuration |
|
public class ValidatorConfig { |
|
@Bean |
|
public Validator validator() { |
|
ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class) |
|
.configure() |
|
// 快速失败模式 |
|
.failFast(true) |
|
// .addProperty( "hibernate.validator.fail_fast", "true" ) |
|
.buildValidatorFactory(); |
|
return validatorFactory.getValidator(); |
|
} |
|
|
|
}
|
|
|