SpringBoot swagger-ui.html 配置类继承 WebMvcConfigurationSupport 类后 请求404

1 、SpringBoot启动类加上  注解 @EnableWebMvc

@SpringBootApplication
@EnableWebMvc

public class Application {
   public static void main(String[] args) {
      SpringApplication.run(Application.class, args);
   }
}

2、 继承 WebMvcConfigurationSupport 加载配置类重写原有 addResourceHandlers 方法,添加需过滤地址

@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
            .addResourceLocations("classpath:/META-INF/resources/");
    registry.addResourceHandler("/webjars/**")
            .addResourceLocations("classpath:/META-INF/resources/webjars/");
}


3、 检查项目中其它拦截器拦截请求代码

接下来访问 http://localhost:8088/swagger-ui.html

 
原文地址:https://www.cnblogs.com/dunkbird/p/13852990.html