首页 > 解决方案 > 从 springfox2 迁移到 springfox 3.0

问题描述

我的 springboot 应用程序使用了 springfox2。我尝试迁移到 springfox3(“io.springfox:springfox-boot-starter:3.0.0”)。我按照https://springfox.github.io/springfox/docs/current/#example-application第 2.1.3 节中的步骤进行操作。从现有的 2.x 版本迁移。此外,我替换了一些不推荐使用的类(例如 globalRequestParameters、globalResponses、schma 等),但生成的文档存在一些问题。有人有文档或示例吗?非常感谢!!

问题:服务器 url 显示 localhost

招摇 yaml 文件显示

openapi: 3.0.3
info:
  title: api title 
  description: api description
  version: '1'
servers:
  - url: 'http://localhost:8081'
    description: Inferred Url

我希望服务器 url 成为我的 api 服务器 url 而不是 localhost。我试过了:

    return new Docket(DocumentationType.OAS_30)
            .groupName("host url")  //if comment out this, it will retrun localhost
            .host("host url")
            ...

设置了 groupName,这将返回 404 错误

标签: javaspring-bootopenapiswagger-2.0springfox

解决方案


推荐阅读