Search code examples
spring-bootswaggerupgradestartupspringfox

Spring fox dependency does not resolve the error when upgrading to Springboot 3.1.0


There is a micro-service, which is implemented on top of Springboot 2.5.8 and it is required to be upgraded to Springboot 3.1.0. During the upgrade the following error was shown when starting up the application.

org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'
at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:181) ~[spring-context-6.0.9.jar!/:6.0.9]
at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356) ~[spring-context-6.0.9.jar!/:6.0.9]
at java.base/java.lang.Iterable.forEach(Iterable.java:75) ~[na:na]
at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:155) ~[spring-context-6.0.9.jar!/:6.0.9]
at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:123) ~[spring-context-6.0.9.jar!/:6.0.9]

In order to resolve this, the following changes were done but still the error is there. Can anyone has come across this situation?

  1. Updated dependencies needed for swagger (previously it was spring-fox 2.9.2 version)

     <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-boot-starter</artifactId>
        <version>3.0.0</version>
    </dependency>
    
  2. Added the following configuration in application.yml and checked

    spring.mvc.pathmatch.matching-strategy: ant_path_matcher

However, none of the above solutions didn't resolve the above issue. Does anyone has come across this situation and found answers?


Solution

  • It appears that the springfox-boot-starter version 3.0.0 lacks compatibility with Spring Boot 3. Consider switching to SpringDoc v2 which does support it and is actively maintained.