【Swagger】SpringBoot整合Swagger出现Unable to infer base url. This is common when using dynamic问题

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

【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:

在这里插入图片描述

问题解决

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

  1. swagger的版本太高了 换成2.7.0版本即可
    在这里插入图片描述

  2. swagger配置文件上没有加@EnableSwagger2注解
    在这里插入图片描述

  3. 主启动类上加上@EnableSwagger2注解 【这个方法我就不采取了!!!因为我项目刚写好的时候,没有加这个注解就是可以运行的,所以我这里并不认为是这个问题】

  4. 将maven重新编译、浏览器数据清理一下 【我这里将重新编译 并且将浏览器内存清理以后,就可以正常运行了】

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值