Replace @EnableSwagger2 after update to latest version

Peter Penzov picture Peter Penzov · Jun 23, 2020 · Viewed 9.3k times · Source

I migrated to latest springfox-swagger2 version 2.10.0 but looks like @EnableSwagger2 is deprecated.

What annotation should I use in order to enable Swagger into Spring Boot project? @EnableSwagger2WebMvc?

Answer

vaquar khan picture vaquar khan · Oct 8, 2020

@EnableSwagger2 was deprecated in swagger 2.10+

@EnableSwagger2WebMvc is deprecated in 3.0.0+

Funny but true :)

Now you can use following dependency with Spring 5 MVC

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

and

  • remove explicit dependencies on springfox-swagger2
  • remove the @EnableSwagger2 annotations
  • add the springfox-boot-starter dependency

see: https://github.com/springfox/springfox