简体   繁体   中英

Unable to upgrade swagger2 version from 2.7.0 to 3.00 in Spring REST API(regular Spring not sprint boot)

My project is working fine with swagger2 version 2.7.0.not spring boot(spring mvc only) I am going to upgrade it 3.0.0 but it's giving plugin errors.

java.lang.nosuchMethodError:org.springframework.plugin.core.pluginRegistry.getPluginFor(Ljava/lang/Object;)Ljava/util/Optional;

My config as below:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0</version>
</dependency>

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>


Update: As mentioned in https://github.com/springfox/springfox
Step 2 : Add @EnableOpenApi for open API (and @EnableSwagger2WebMvc or @EnableSwagger2WebFlux for older versions)
I added @EnableSwagger2WebMvc in class ,Then it's asking dependency of springfox-swagger2,
as this coming from :
http://springfox.github.io/springfox/javadoc/snapshot/springfox/documentation/swagger2/annotations/EnableSwagger2WebMvc.html 
which is part of springfox-swagger2 dependency

Hence I am confused what to do..
can you please help cleaner approach with steps .
If I don't  use @EnableSwagger2WebMvc/EnableSwagger2
Swagger is not getting loaded

Not sure if you are using Spring Boot, or regular Spring flavor, but have you followed the migration instructions posted here?

https://github.com/springfox/springfox

  1. Remove explicit dependencies on springfox-swagger2
  2. Remove any @EnableSwagger2... annotations
  3. Add the springfox-boot-starter (Spring boot) or springfox-oas (Spring MVC) dependency
  4. Check if you do not rely on removed dependecy on guava
  5. If you are using WebMvc but you don't use the @EnableWebMvc annotation yet, add this annotation (Spring boot).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM