Spring Boot自动配置本身不会自动把/swagger-ui.html这个路径映射到对应的目录META-INF/resources/下面。我们需要对这个资源释放拦截
需要继承WebMvcConfigurerAdapter对资源释放拦截
/** * Created by csy on 2017/6/9 * 资源拦截 */ @Configuration @EnableWebMvc//会覆盖掉SpringBoot的默认的静态资源映射配置 @ComponentScan(value = {"com.daze.jiedai.controller"}) class SpringConfig extends WebMvcConfigurerAdapter { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("swagger-ui.html") .addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/"); }