| | |
| | | package com.ruoyi.common.core.config; |
| | | |
| | | import jakarta.validation.Validator; |
| | | import org.hibernate.validator.HibernateValidator; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.boot.autoconfigure.AutoConfiguration; |
| | | import org.springframework.context.MessageSource; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; |
| | | |
| | | import jakarta.validation.Validator; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | |
| | | @AutoConfiguration |
| | | public class ValidatorConfig { |
| | | |
| | | @Autowired |
| | | private MessageSource messageSource; |
| | | |
| | | /** |
| | | * 配置校验框架 快速返回模式 |
| | | */ |
| | | @Bean |
| | | public Validator validator() { |
| | | public Validator validator(MessageSource messageSource) { |
| | | LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean(); |
| | | // 国际化 |
| | | factoryBean.setValidationMessageSource(messageSource); |