【问题标题】:OpenApi/Swagger with Spring boot integration issue带有 Spring Boot 集成问题的 OpenApi/Swagger
【发布时间】:2021-12-21 18:10:42
【问题描述】:

我正在尝试将 openApi 与 swagger 集成到我的 Spring Boot 应用程序中。 swagger UI 加载,但是它没有找到渲染页面所需的 swaggerjson 文件。

我添加了以下依赖项:

        <dependency>
            <groupId>org.springdoc</groupId>
            <artifactId>springdoc-openapi-ui</artifactId>
            <version>1.5.12</version>
        </dependency>
        <!-- required for swagger-ui integration -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>

这是我的配置类:

@Configuration
public class SwaggerConfig {
    @Bean
    public OpenAPI customOpenAPI() {
        return new OpenAPI().info(new Info()
                .title("Service API")
                .version("1")
                .description("Service"));
    }
}

这是错误:

Ambiguous handler methods mapped for '/v3/api-docs': {public org.springframework.http.ResponseEntity springfox.documentation.oas.web.OpenApiControllerWebMvc.getDocumentation(java.lang.String,javax.servlet.http.HttpServletRequest), public java.lang.String org.springdoc.webmvc.api.OpenApiWebMvcResource.openapiJson(javax.servlet.http.HttpServletRequest,java.lang.String,java.util.Locale) throws com.fasterxml.jackson.core.JsonProcessingException

【问题讨论】:

    标签: spring-boot swagger openapi springfox springdoc-openapi-ui


    【解决方案1】:

    我认为您不能同时使用这些依赖项。他们都做同样的事情,这意味着你得到了“模棱两可”的错误。 This 有一些关于从 springfox 迁移的详细信息。

    【讨论】:

      猜你喜欢
      • 2020-12-18
      • 2018-09-18
      • 1970-01-01
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多