Swagger-ui.html进不去 显示Unable to infer base url...

整了一个根据当前运行环境是否为 (dev,test,pro) 去显示是否开启swagger:

@Bean
public
Docket docket(Environment environment) { // 设置要显示的swagger 环境 Profiles p = Profiles.of("dev","test"); // 通过environment.acceptsProfiles 判断是否处在自己设定的环境中 boolean b = environment.acceptsProfiles(p); return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()) .enable(b) .select() .apis(RequestHandlerSelectors.basePackage("top.nosoul.controller")) .build(); }

运行项目之后  发现显示:

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:

解决办法:

  将端口号改成 设置环境对应的端口号


__EOF__

本文作者无魂儿
本文链接https://www.cnblogs.com/nosouln/p/12788093.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   无魂儿  阅读(3254)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
点击右上角即可分享
微信分享提示