配置虚拟路径,用于图片展示等

@Configuration
public class WebMvcConfig extends WebMvcConfigurerAdapter {


@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**")
//swagger路径
.addResourceLocations("classpath:/META-INF/resources/")
//虚拟化图片/音乐路径
.addResourceLocations("file:D:/eclipsework/xiaochengxu/imooc-videos-dev/");
}

}


因为用的是swagger2,之前没有配置这个,需要单弄一个tomcat作为图片服务器地址。现在启动好了之后,直接

localhost:xxxx/ 你的图片相对于虚拟化的路径xxx.jpg 就可以访问了 

猜你喜欢

转载自blog.csdn.net/qq1134585484/article/details/80719438