首先Spring Boot自动配置本身不会自动把/swagger-ui.html这个路径映射到对应的目录META-INF/resources/下面。
所以我们需要动态的进行mvc资源文件的指定
/**
* <Description> <br>
*
* @author luoluocaihong<br>
* @version 1.0<br> * @taskId <br> * @CreateDate Jul 2, 2017 <br> * @since V8.0<br> * @see XXXX <br> */ @Configuration public class WebMVCConfig 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/");
}
}
配置完之后 在重新打开 http://localhost:8080/swagger-ui.html
完美解决!