Springboot 2.x 外部資原始檔配置
阿新 • • 發佈:2019-01-28
springboot1.5的寫法過時,2.x版本寫法如下
@Configuration //@EnableWebMvc public class MvcConfig implements WebMvcConfigurer { @Value("${file.staticAccessPath}") private String staticAccessPath; @Value("${file.uploadFolder}") private String uploadFolder; @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler(staticAccessPath).addResourceLocations("file:" + uploadFolder); //registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); } }