Swagger问题:No mapping for GET /swagger-ui.html报错

Swagger问题:No mapping for GET /swagger-ui.html报错

简介:本文讲解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);
    }

}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_51447496/article/details/132536561
今日推荐