错误产生环境

SpringBoot 整合 Swagger2,配置扫描接口和配置是否启用swagger2是产生

判断swagger2 在生产环境下才能使用

  1. 获取当当前的环境,判断是不是生产环境
  2. 如果是则启用swagger2 如果不是则不开启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: 

在这里插入图片描述

错误原因

在这里插入图片描述
我已经启用开发环境了
在这里插入图片描述
但是访问swagger 的时候一值一直弹出提示,
原因是我开发环境端口是8081 我却一直访问默认的端口 8080 从而导致一直弹出弹窗
在这里插入图片描述

解决办法

访问8081端口
在这里插入图片描述

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐