【Swagger】SpringBoot结合Swagger显露Unabletoinferbaseurl.Thisiscommonwhenusingdynamic方面

原创
小哥 3年前 (2022-11-07) 阅读数 7 #大杂烩

【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重新编译和清理浏览器数据 [我将在此处重新编译 清理浏览器内存后,它可以正常运行]]

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除