【发布时间】:2021-03-26 15:09:26
【问题描述】:
我将swagger-ui 添加到我的spring-boot 服务应用程序中,但在访问/swagger-ui/ 链接时出现了类似的错误。
Error in browser console please see the image(click this link)
我在招摇中的参考来自这里:
https://www.baeldung.com/swagger-2-documentation-for-spring-rest-api
这里是我的配置示例代码:
@Configuration
public class WebConfiguration implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LoggerInterceptor());
}
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
我尝试排除这部分:
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
仍然没有解决。希望有人可以提供帮助。谢谢。
【问题讨论】:
标签: spring-boot swagger-ui springfox-boot-starter