From 3b7d2d743514cf3793c07daa5f0e1d8aca4cd528 Mon Sep 17 00:00:00 2001 From: xiangpei <xiangpei@timesnew.cn> Date: 星期日, 28 四月 2024 10:09:18 +0800 Subject: [PATCH] 文件访问bug修改 --- ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java | 21 +++++++++++++++++++-- 1 files changed, 19 insertions(+), 2 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java b/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java index 2531656..81afe43 100644 --- a/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java +++ b/ycl-server/src/main/java/com/ycl/config/ResourcesConfig.java @@ -1,26 +1,43 @@ 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());; + } /** * 璺ㄥ煙閰嶇疆 @@ -80,4 +97,4 @@ return localeResolver; } -} \ No newline at end of file +} -- Gitblit v1.8.0