SpringBoot swagger-ui.html 配置類繼承 WebMvcConfigurationSupport 類後 請求404

1 、SpringBoot啓動類加上  註解 @EnableWebMvchtml

@SpringBootApplication
@EnableWebMvc

public class Application {
 public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
二、 繼承 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/");
}

三、檢查項目中其它攔截器攔截請求代碼

接下來訪問 http://localhost:8088/swagger-ui.html

 

相關文章
相關標籤/搜索