一、错误描述

Spring Boot项目连接Swagger报错:

Unable to infer base url. This is common when using dynamic servlet 
registration or when the API is behind an API Gateway.
The base url is the root of where all the swagger resources are served. 
For e.g. if the api is available at http://example.org/api/v2/api-docs then the base url is 
http://example.org/api/. Please enter the location manually: 

在这里插入图片描述

二、解决办法
报出错误之后,在网上找了很多的解决办法,尝试过修改路径和不断刷新,去清除缓存,但是问题都没有得到实质性的解决。

我是在启动类中添加了**@EnableSwagger2**注解。

在这里插入图片描述
在这里插入图片描述
如果问题还没有得到解决,可以参考下面的两篇博客。

参考博客:
https://blog.csdn.net/just_now_and_future/article/details/89343680

https://zhaoxuyang.com/springboot%E4%BD%BF%E7%94%A8swagger2%E5%87%BA%E7%8E%B0unable-to-infer-base-url-this-is-common-when-using-dynamic-servlet-registration-or-when-the-api-is-behind-an-api-gateway/?replytocom=364

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐