8

I'm trying to run my Spring boot application which is based on version 3.0 with swagger UI and I'm getting a lot of exceptions I have explored many sources like youtube and documentation but I'm unable to find the solution.

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

if any one can share the solution it will be very nice.

Helen
  • 87,344
  • 17
  • 243
  • 314
Rohan Mourya
  • 83
  • 1
  • 1
  • 5

3 Answers3

13

SpringFox is for all intents and purposes dead / abandoned project. It hasn't has a release since July 2020, note the 3.0.0 is their support for Spring Boot 2.0.0. The breaking API changes, if you haven't already been affected by them in prior releases, have finally broken it for you with the latest Spring Boot 3.0.0 which introduces significant breaking changes in Spring Framework and Spring Boot.

One of which is a change to how Autoconfiguration's must be registered in Spring Boot. The old method was deprecated in 2.7.0 and removed in 3.0.0. Springfox will not work without manually creating the beans required, and this is assuming that there is not more breaking changes in the other Spring components it uses.

There is an alternative in the form of SpringDoc which gives you the same functionality of Springfox's implementation of the OpenAPI / Swagger spec and more.

There is a simple migration guide to move from Springfox to SpringDoc.

Darren Forsythe
  • 10,712
  • 4
  • 43
  • 54
  • 1
    I'm using SpringDoc already and Springboot 3 broke that for me as well – TrollBearPig Dec 31 '22 at 05:02
  • @TrollBearPig hey are you able to find a fix? I am also not able to open swagger ui anymore. I am using SpringDoc and Springboot 3. – Amjad Aziz Jan 23 '23 at 07:30
  • 2
    @AmjadAziz Hi yes I did. It turned out to be a simple fix of changing the pom dependency. SRC: https://stackoverflow.com/questions/74701738/spring-boot-3-springdoc-openapi-ui-doesnt-work – TrollBearPig Jan 23 '23 at 23:32
5

for spring boot 3 use

<dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.1.0</version>
 </dependency>
MM MM
  • 51
  • 1
  • 1
0
<dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.1.0</version>
 </dependency>
package com.surya;


import org.springdoc.core.models.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
public class SpringDocConfig {

  
    @Bean
    public GroupedOpenApi controllerApi() {
        return GroupedOpenApi.builder()
                .group("controller-api")
                .packagesToScan("com.surya.controller") // Specify the package to scan
                .build();
    }



}
surya
  • 1
  • 1
    Please read [answer] and [edit] your answer to contain an explanation as to why this code would actually solve the problem at hand. Always remember that you're not only solving the problem, but are also educating the OP and any future readers of this post. – Adriaan Aug 22 '23 at 10:25
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 25 '23 at 10:07