Springboot 2.x 外部资源文件配置

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/");
	}

}

你可能感兴趣的:(Spring,Boot)