package com.sandu.common.config; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; /** * @author chenjiantian * @date 2021/8/3 11:28 */ @Configuration public class ResWebAppConfigurer implements WebMvcConfigurer { @Value("${sandu.upload.upload-root-path}") String uploadRootPath; @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/file/**").addResourceLocations("file:" + uploadRootPath); } }