spring-bootswaggerswagger-ui

swagger 3 import not found after spring 3 update


There has been post similar to my issue but I have all the correct dependentcies. I also have another application that is working with swagger 3 that I just updated to spring 2 -> 3. I am struggling to figure out why this very small helper repo cannot resolve swagger 3.

maven pom.xml

<springfox-swagger.version>3.0.0</springfox-swagger.version>
<swagger.version>2.2.15</swagger.version>
<springdoc.version>2.5.0</springdoc.version>

  <!-- ................................................................= -->
  <!-- Springfox -->
  <!-- ................................................................= -->
  <dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
  </dependency>

  <!-- ................................................................= -->
  <!-- Swagger -->
  <!-- ................................................................= -->
  <dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-annotations</artifactId>
    <version>${swagger.version}</version>
  </dependency>
  <dependency>
    <groupId>io.swagger.core.v3</groupId>
    <artifactId>swagger-models</artifactId>
    <version>${swagger.version}</version>
  </dependency>
  <dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>${springdoc.version}</version>
  </dependency>

The app fails because classes that are generated via openapi cannot resolve swagger.

Has anyone has a similar experience?

enter image description here


Solution

  • SpringFox hasn't been updated since June 2020, and its latest version, 3.0.0, supports Spring Boot 2.0.0.

    You might need to switch to SpringDoc, which is compatible with Spring Boot 3.0.0 and onwards.

    This migration guide will be a great help to you

    Gradle

    implementation group: 'org.springdoc', name: 'springdoc-openapi-starter-webmvc-ui', version: '2.2.0'
    
    

    Maven

    <dependency>
        <groupId>org.springdoc</groupId>
        <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
        <version>2.2.0</version>
    </dependency>
    

    The following posts seem to be experiencing similar things as you are.

    1. spring boot 2.5.6 without spring security and security config upgraded to spring boot 3 making swagger not working
    2. Spring boot 3 doesn't work with springfox 3.0