springboot配置文件配置静态资源文件,swagger不能访问

Springboot配置静态资源swagger-ui.html不能访问


application.properties配置:

spring.resources.static-locations=classpath:/static/,file:uploadFiles/

解决方案:

类方法配置


import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**

* @author xianxiong

*/

@Configuration

public class InterceptorConfigurerAdapter extends WebMvcConfigurerAdapter{

@Override 

    public void addResourceHandlers(ResourceHandlerRegistry registry) { 

        registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0); 

    }

}

你可能感兴趣的:(springboot配置文件配置静态资源文件,swagger不能访问)