|
|
@ -16,14 +16,18 @@ import org.springframework.boot.autoconfigure.web.client.RestTemplateAutoConfigu |
|
|
|
import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
|
|
import org.springframework.boot.web.client.RestTemplateBuilder; |
|
|
|
import org.springframework.boot.web.servlet.FilterRegistrationBean; |
|
|
|
import org.springframework.context.MessageSource; |
|
|
|
import org.springframework.context.annotation.Bean; |
|
|
|
import org.springframework.util.AntPathMatcher; |
|
|
|
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.client.RestTemplate; |
|
|
|
import org.springframework.web.cors.CorsConfiguration; |
|
|
|
import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
|
|
|
import org.springframework.web.filter.CorsFilter; |
|
|
|
import org.springframework.web.servlet.LocaleResolver; |
|
|
|
import org.springframework.web.servlet.config.annotation.*; |
|
|
|
import org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.Filter; |
|
|
@ -46,6 +50,23 @@ public class WinWebAutoConfiguration implements WebMvcConfigurer { |
|
|
|
configurePathMatch(configurer, webProperties.getAdminApi()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置validator国际化 |
|
|
|
* @param messageSource |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Bean |
|
|
|
public LocalValidatorFactoryBean defaultValidator(MessageSource messageSource) { |
|
|
|
LocalValidatorFactoryBean factoryBean = new LocalValidatorFactoryBean(); |
|
|
|
factoryBean.setValidationMessageSource(messageSource); |
|
|
|
return factoryBean; |
|
|
|
} |
|
|
|
|
|
|
|
@Bean |
|
|
|
public LocaleResolver localeResolver() { |
|
|
|
return new AcceptHeaderLocaleResolver(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置 API 前缀,仅仅匹配 controller 包下的 |
|
|
|
* |
|
|
|