spring-bootspringdoc-openapi-uiopenrewrite

ClassNotFoundException: org.springframework.web.servlet.resource.LiteWebJarsResourceResolver when running Spring Boot 3.3 best practices recipe


I am running org.openrewrite.java.spring.boot3.SpringBoot33BestPractices recipe of OpenRewrite on a Spring Boot v3.3.8 project that uses SpringDoc Api v2.6.0. OpenRewrite is upgrading correctly the Spring Boot version to v3.3.12 but it is also upgrading SpringDoc Api to v2.8.9 and I would say that it is wrong because now I am getting a java.lang.ClassNotFoundException: org.springframework.web.servlet.resource.LiteWebJarsResourceResolver error.

It seems the error is because that class was introduced in Spring Framework v6.2.0 but that version is only supported from Spring Boot v3.4.0 and above, so the recipe should be updating SpringDoc Api to 2.6.x versions based on this compatibility matrix: https://springdoc.org/#what-is-the-compatibility-matrix-of-springdoc-openapi-with-spring-boot I also found the same error here: Springdoc: ClassNotFoundException: org.springframework.web.servlet.resource.LiteWebJarsResourceResolver.

I have checked the code of the recipe here https://github.com/openrewrite/rewrite-spring/blob/main/src/main/resources/META-INF/rewrite/springdoc.yml#L144 and I would say that the error is that the recipe does not take into account the Spring Boot version to update SpringDoc Api dependencies to the compatible ones and it always updated it to the latest one.

See below the console logs for transitive recipes executed:

[INFO] Printing available datatables to: target/rewrite/datatables/2025-06-16_13-57-16-961
[WARNING] These recipes would make changes to pom.xml:
[WARNING]     internal.recipe.springboot.BestPractices
[WARNING]         org.openrewrite.java.spring.boot3.SpringBoot33BestPractices
[WARNING]             org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_3
[WARNING]                 org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_2
[WARNING]                     org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_1
[WARNING]                         org.openrewrite.java.spring.boot3.UpgradeSpringBoot_3_0
[WARNING]                             org.openrewrite.java.springdoc.UpgradeSpringDoc_2
[WARNING]                                 org.openrewrite.java.dependencies.UpgradeDependencyVersion: {groupId=org.springdoc, artifactId=*, newVersion=2.x}

Is there a way to configure the recipe to use the correct SpringDoc Api version depending on the Spring Boot version the recipe is migrating to based on the compatibility matrix I added above?


Solution

  • Thanks for the report Jesus; Should be fixed following:
    https://github.com/openrewrite/rewrite-spring/pull/735