gpt4 book ai didi

compatibility - springdoc-openapi + Spring 4 兼容性

转载 作者:行者123 更新时间:2023-12-04 10:14:25 43 4
gpt4 key购买 nike

我有一个现有的 Spring 4 API,并已成功集成 springdoc-openapi 以在 JSON/YAML 中生成 OpenAPI 3 规范,还使用 ​​springdoc-openapi 1.2.29 和 Spring Boot 15.2.2.RELEASE 显示 Swagger UI,但是在 springdoc-openapi 的更高版本中似乎修复了各种错误并添加了增强功能。不幸的是,如果我使用高于 springdoc-openapi 1.2.29 的版本,我会遇到 Spring 4 的各种兼容性问题。

是否有 springdoc-openapi 和 Spring 4 的可用性兼容性矩阵?当我通读 springdoc-openapi 文档时,我没有看到任何自述文件或发行说明表明存在 Spring 5 要求,但是如下所述,一旦达到某个版本,底层 springdoc-openapi 中就会使用 Spring 5 类。

我的相关 POM:

    <!-- springdoc-openapi-ui -->
<!-- anything over 1.2.33 uses Spring 5 MethodParameter.getParameter()-->
<!-- anything over 1.2.29 uses Spring 5 org.springframework.http.codec.multipart.FilePart -->
<!-- webjars-locator-jboss-vfs is required for running under JBOSS and exposing the swagger-ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.2.29</version>
</dependency>
<!--
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-security</artifactId>
<version>1.2.29</version>
</dependency>
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>1.5.22.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>1.5.22.RELEASE</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>webjars-locator-jboss-vfs</artifactId>
<version>0.1.0</version>
</dependency>

当使用 springdoc-openapi-ui 1.2.30 时,它随后会引入 springdoc-openapi-common-1.2.30.jar,它会在尝试使用 org.springframework.http.codec.multipart.FilePart 时抛出异常。同样,使用 1.2.34 或更高版本将在 MethodParameter.getParameter() 上抛出异常。

12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) Caused by: java.lang.NoClassDefFoundError: org/springframework/http/codec/multipart/FilePart
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.core.GenericParameterBuilder.isFile(GenericParameterBuilder.java:271)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.core.GenericParameterBuilder.isFile(GenericParameterBuilder.java:296)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.core.AbstractRequestBuilder.buildParams(AbstractRequestBuilder.java:271)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.core.AbstractRequestBuilder.build(AbstractRequestBuilder.java:174)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.api.AbstractOpenApiResource.calculatePath(AbstractOpenApiResource.java:205)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.api.OpenApiResource.calculatePath(OpenApiResource.java:134)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.api.OpenApiResource.getPaths(OpenApiResource.java:99)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.api.AbstractOpenApiResource.getOpenApi(AbstractOpenApiResource.java:124)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springdoc.api.OpenApiResource.openapiJson(OpenApiResource.java:83)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
12:15:05,003 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at java.lang.reflect.Method.invoke(Method.java:498)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:116)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
12:15:05,004 ERROR [stderr] (ajp-localhost/127.0.0.1:8009-1) ... 61 more

Spring 5 引用:https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/http/codec/multipart/FilePart.html

public interface FilePart
extends Part

Specialization of Part that represents an uploaded file received in a multipart request.

Since:
5.0

关于如何解决此问题以在更高版本中利用 springdoc-openapi 中的错误修复和增强功能的任何建议?

最佳答案

问题已确认并将作为 1.3.3 的一部分得到解决。请查看下面使用 Springdoc 记录的问题。感谢@bnasslahsen 令人难以置信的快速识别和更正!

https://github.com/springdoc/springdoc-openapi/issues/563

关于compatibility - springdoc-openapi + Spring 4 兼容性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61144044/

43 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com