【Swagger】SpringBoot整合Swagger出现Unable to infer base url. This is common when using dynamic问题
问题描述
写好的项目,时隔多日再次打开,修改了一下接口以后,想要打开swgger接口文档来测试写好的接口时,出现了下面的问题:
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:

问题解决
出现问题以后有些许不理解,因为后续的修改全部是围绕接口进行操作的,压根没有修改任何配置等东西,就突然出现这个问题了,在网上查找了很多资料,可能出现这个问题的原因有:
-
swagger的版本太高了 换成
2.7.0版本即可

-
swagger配置文件上没有加
@EnableSwagger2注解

-
主启动类上加上
@EnableSwagger2注解 【这个方法我就不采取了!!!因为我项目刚写好的时候,没有加这个注解就是可以运行的,所以我这里并不认为是这个问题】 -
将maven重新编译、浏览器数据清理一下 【我这里将重新编译 并且将浏览器内存清理以后,就可以正常运行了】

本文介绍了SpringBoot项目中整合Swagger时遇到的Unabletoinferbaseurl问题及其解决方案。问题可能源于Swagger版本过高、配置缺失等原因,文中提供了具体步骤帮助读者解决该问题。

2万+

被折叠的 条评论
为什么被折叠?



