Suddenly Springfox Swagger 3.0 is not working with spring webflux
This is how it worked for me. I am using InteliJ IDEA, SpringBoot and Maven.
When adding Swagger dependencies as:
<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>
They were colored in red and I could not add them at all. I tried reloading my project, generate sources and update folders, but I just couldn't install it.
Then I added this dependency as well:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
And it worked just fine. Also, I find my conclusion to the problem here:
Baeldung
So in the end I had this in my pom.xml file:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
<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>
To see Swagger UI in your browser using Swagger 3.0 is
http://localhost:8080/swagger-ui/index.html
Hope it helps to someone :)
Getting Started with Swagger-3 in Springboot Rest API
For new projects
For Maven:-
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>3.0.0</version>
</dependency>
For Gradle:-
implementation "io.springfox:springfox-boot-starter:<version>"
Now there is no extra configuration to activate swagger
on the spring-boot project like the previous. if try to configure with security, there is some configuration. plz refer to this article.
In swagger version 3 remove the @EnableSwagger2
annotation base config also.
And most of the user tries to find HTML swagger document file using {host}/swagger-ui.html
or {host}/swagger-ui
those are now removed.
use {host}/swagger-ui/
to see the HTML document
This is a sample project link on GitHub
Refer to documentation io.springfox
The implementation has changed recently (see migrating from earlier snapshots for a brief update on this).
Now the UI is avaiable under /swagger-ui
endpoint (not /swagger-ui.html
).
You should also drop the @EnableSwagger2WebFlux
annotation and addResourceHandlers()
method, remove all springfox dependencies and add just one:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
<version>${springfox.version}</version>
</dependency>