我有一个现有的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
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致以难以置信的快速识别和更正!