如何修复Spring Boot 3.2下实现Swagger后Theprovideddefinition does notspecify a valid version field的错误
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.3.0</version>
</dependency>
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
final Collection<HttpMessageConverter<?>> myConverters = new ArrayList<>();
final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
builder.serializerByType(ObjectId.class, new ToStringSerializer());
final HttpMessageConverter<Object> converter = new MappingJackson2HttpMessageConverter(builder.build());
myConverters.add(converter);
myConverters.addAll(converters);
converters.clear();
converters.addAll(myConverters);
}
springdoc:
writer-with-default-pretty-printer: true
swagger-ui:
display-request-duration: true
disable-swagger-default-url: true
api-docs:
version: openapi_3_1
下面我就给你答案!