openrewrite / rewrite-spring

OpenRewrite recipes for Spring projects.
Apache License 2.0
237 stars 64 forks source link

Migrating Spring Boot 1.5 to 2.7 and facing issues in MongoDB #547

Open aakash03chaudhari opened 5 days ago

aakash03chaudhari commented 5 days ago

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:

1) public BulkWriteOperation bulkLoader; public BulkWriteOperation bulkLoaderForBreakendInfo;

should be converted to:

public BulkOperations bulkLoader; public BulkOperations bulkLoaderForBreakendInfo;

2) 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
timtebeek commented 5 days ago

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.