package com.shiers.config;import org.springframework.context.annotation.Configuration;import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;/** * Demo class * * @author shierS * @date 2021/6/5 */@Configurationpublic class WebMvcConfig implements WebMvcConfigurer { /** * 实现静态资源的注册: * Add handlers to serve static resources such as images, js, and, css files * from specific locations under web application root, the classpath, and others. * 添加处理程序来服务静态资源,如图片,js,和,css文件从特定位置下的web应用程序根,类路径,和其他。 * @param registry */ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**") // 映射swagger2 .addResourceLocations("classpath:/META-INF/resources/") //映射本地静态资源 .addResourceLocations("file:D:\\Environment\\apache-tomcat-9.0.46\\webapps\\images\\"); }}