从 springfox swagger 迁移到 openAPI 后 Swagger url 不起作用

问题描述

我有 springfox swagger2,其中 http://localhost:8080/context/swagger-ui.html 工作正常。 现在我已经修改了所有更改以使其可运行 open-api。
使用:Migrating from springfox swagger2 to springdoc openapi

现在我可以使用如下组名打开我的服务定义 json:

http://localhost:8080/context-path/v3/api-docs/groupName

但无法像我之前使用 springfox 2.0 那样打开 swagger-ui.html

你能帮我吗,如何打开以及网址应该是什么?
当我输入 http://localhost:8080/context/swagger-ui.html 时,它正在创建如下所示的新路由并且没有打开任何东西,404 错误

http://localhost:8080/context/swagger-ui/index.html?configUrl=/context/v3/api-docs/swagger-config

请注意,我已经在我的项目中添加了 swagger-ui.html,因为它已经为 swagger 2.0 添加

public void addResourceHandlers(ResourceHandlerRegistry registry) {
    registry.addResourceHandler("swagger-ui.html")
      .addResourceLocations("classpath:/meta-inf/resources/");

    registry.addResourceHandler("/webjars/**")
      .addResourceLocations("classpath:/meta-inf/resources/webjars/");

请帮助获得swagger主屏幕,以便我可以测试休息服务

解决方法

问题是 Swagger-UI 暴露在 http://localhost:8080/swagger-ui.html

如果您希望 Swagger-UI 应位于上下文根下,请更新 application.properties 文件中的以下属性或其等效项。

springdoc.swagger-ui.path=/your-context-path/swagger-ui.html

可以找到属性列表here