上传图片到服务器,第一次是404,需要进入项目才会加载图片的问题
配置加载资源
@Configuration
public class WebMvcConfigure implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**")
.addResourceLocations("file:E:/benke/lx/travel/src/main/resources/static/")
.addResourceLocations(ResourceUtils.CLASSPATH_URL_PREFIX+ "/static/");
}