I am trying to configure OpenAPI with swagger to my existing non-spring boot application.
Spring v.5.1.8.RELEASE SpringDoc v.1.4.6 Spring-boot v.2.3.2.RELEASE
Open doc and swagger with spring mv
My application is not spring boot enable that’s why I have following dependencies in my Pom copied from article linked above
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>last.version</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>2.1.11.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
<version>2.1.11.RELEASE</version>
</dependency>
My Spring mvc project already has servlet context configuration so I assumed I only need to register/import open api and swagger configuration files.
So I did the following
@EnableMvc
@Configuration
@import({org.springdoc.ui.SwaggerConfig.class,
org.springdoc.core.SwaggerUiConfigProperties.class, org.springdoc.core.SwaggerUiOAuthProperties.class,
org.springdoc.webmvc.core.SpringDocWebMvcConfiguration.class,
org.springdoc.webmvc.core.MultipleOpenApiSupportConfiguration.class,
org.springdoc.core.SpringDocConfiguration.class, org.springdoc.core.SpringDocConfigProperties.class,
org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration.class
@Bean
Public OpenAPI(){
return new OpenAPI();
}
When I run my application I gets the following error
“Java.lang.NoSuchMethodError:org.springframework.core.type.AnnotatgedTypeMetadata.getAnnotations()/Lorg/springframework/core/annotations/MergeAnnotations”
It was caused due to incompatible version of spring mvc and spring-boot