赞
踩
简介:本文讲解No mapping for GET /swagger-ui.html这个报错的解决方法。
只需要对SwaggerConfig的配置类继承WebMvcConfigurer,然后加上重载方法就好了。
@Configuration
@EnableWebMvc
@EnableSwagger2 // 开启Swagger2
public class SwaggerConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations(
"classpath:/static/");
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/");
WebMvcConfigurer.super.addResourceHandlers(registry);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。