| | |
| | | package com.ycl.config; |
| | | |
| | | import constant.Constants; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.http.CacheControl; |
| | | 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.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
| | | import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; |
| | | import org.springframework.web.servlet.i18n.SessionLocaleResolver; |
| | | |
| | | import java.util.Locale; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 通用配置 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Configuration |
| | | public class ResourcesConfig implements WebMvcConfigurer |
| | | { |
| | | |
| | | @Override |
| | | public void addResourceHandlers(ResourceHandlerRegistry registry) |
| | | { |
| | | /** 本地文件上传路径 */ |
| | | registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**") |
| | | .addResourceLocations("file:" + PlatformConfig.getProfile() + "/"); |
| | | |
| | | /** swagger配置 */ |
| | | registry.addResourceHandler("/swagger-ui/**") |
| | | .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/") |
| | | .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());; |
| | | } |
| | | |
| | | /** |
| | | * 跨域配置 |
| | |
| | | return localeResolver; |
| | | } |
| | | |
| | | } |
| | | } |