rewrite-spring icon indicating copy to clipboard operation
rewrite-spring copied to clipboard

Migrating Spring Boot 1.5 to 2.7 and facing issues in MongoDB

Open aakash03chaudhari opened this issue 1 year ago • 2 comments

What problem are you trying to solve?

We attempted to migrate our project from Spring Boot 1.5 to 2.7. Our current project uses MongoDB, but the MongoDB code has not been fully migrated. For example:

The following:

public BulkWriteOperation bulkLoader; public BulkWriteOperation bulkLoaderForBreakendInfo;

should be converted to:

public BulkOperations bulkLoader; public BulkOperations bulkLoaderForBreakendInfo;

  1. BasicDBObject should be converted to Document.

To facilitate the migration, we added the OpenRewrite plugins to our pom.xml and ran the recipe using mvn rewrite:run.

Here's the relevant part of our pom.xml:

org.openrewrite.maven rewrite-maven-plugin 5.34.0 org.openrewrite.java.spring.boot2.UpgradeSpringBoot_2_7 org.openrewrite.recipe rewrite-spring 5.13.2

aakash03chaudhari avatar Jun 28 '24 10:06 aakash03chaudhari

Thanks for logging an issue! I think it should be fairly easy to cover these cases, if all we have to do is change those types. YOu can see an example here: https://github.com/openrewrite/rewrite-spring/blob/d49e38ed41300f6234cabc9794fce3959912f894/src/main/resources/META-INF/rewrite/springdoc.yml#L52-L54

In this case we'll want to work out what version of Spring Boot necessitates the change, and then add that change to the corresponding yml file under https://github.com/openrewrite/rewrite-spring/tree/d49e38ed41300f6234cabc9794fce3959912f894/src/main/resources/META-INF/rewrite

Would love it if you're open to contribute that change. Even a draft PR would help kick this off and get it included in next week's release.

timtebeek avatar Jun 28 '24 11:06 timtebeek

Hi @aakash03chaudhari For BulkWriteOperation, BulkOperations, and BasicDBObject Could you please help me with the package name for the above and if any other packages you need recipes, I will help you with the recipe.

Is BulkWriteOperation comes with com.mongodb.BulkWriteOperation?

Thanks, Mahi

bsmahi avatar Jul 16 '24 02:07 bsmahi