Skip to content

Migrate Spring Boot 4 MongoDB modular packages and test starters#1079

Open
Kyran121 wants to merge 5 commits into
openrewrite:mainfrom
Kyran121:migrate-mongodb-modular-starters
Open

Migrate Spring Boot 4 MongoDB modular packages and test starters#1079
Kyran121 wants to merge 5 commits into
openrewrite:mainfrom
Kyran121:migrate-mongodb-modular-starters

Conversation

@Kyran121

@Kyran121 Kyran121 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Migrates the MongoDB-related auto-configuration packages and test starters to their Spring Boot 4.0 modular locations, and adds the dedicated MongoDB test starters conditionally based on which main starter and test-slice annotations are in use.

  • Class renames (Spring Data Mongo auto-configuration):
    • MongoDataAutoConfigurationDataMongoAutoConfiguration
    • MongoReactiveDataAutoConfigurationDataMongoReactiveAutoConfiguration
    • MongoRepositoriesAutoConfigurationDataMongoRepositoriesAutoConfiguration
    • MongoReactiveRepositoriesAutoConfigurationDataMongoReactiveRepositoriesAutoConfiguration
  • Package moves:
    • org.springframework.boot.autoconfigure.data.mongoorg.springframework.boot.data.mongodb.autoconfigure
    • org.springframework.boot.test.autoconfigure.data.mongo (@DataMongoTest, etc.) → org.springframework.boot.data.mongodb.test.autoconfigure
    • org.springframework.boot.actuate.autoconfigure.data.mongo (health contributor autoconfig) → org.springframework.boot.mongodb.autoconfigure.health
    • org.springframework.boot.actuate.autoconfigure.metrics.mongoorg.springframework.boot.mongodb.autoconfigure.metrics
    • org.springframework.boot.actuate.data.mongo (health indicators) → org.springframework.boot.mongodb.health
  • New conditional test-starter recipes: AddSpringBootStarterDataMongoDbTest / AddSpringBootStarterDataMongoDbReactiveTest add spring-boot-starter-data-mongodb-test or -reactive-test based on which main starter (spring-boot-starter-data-mongodb vs -reactive) is present. This precondition is needed because @DataMongoTest is a single shared annotation for both imperative and reactive slices, so usage alone can't tell you which starter to add. Each recipe checks the test-slice annotation in both its pre- and post-migration package location, since these two recipes are independently invocable outside the full MigrateToModularStarters sequence — not just inline steps like the other technologies in this file.

This PR covers the Spring Boot-owned modular package and starter changes for MongoDB; Spring Data MongoDB API-level changes (e.g. UUID/BigDecimal representation defaults) are out of scope and tracked separately.

Verified against

Spring Boot 4.0 is GA. Its migration guide gives the root package prefix for each module via its module table (e.g. spring-boot-mongodborg.springframework.boot.mongodb, spring-boot-data-mongodborg.springframework.boot.data.mongodb) plus a generic "each module starts with org.springframework.boot.<module>" rule, but it doesn't map the specific internal sub-packages or renamed classes. Those mappings were checked directly against the released v4.0.7 source:

recipes.csv's count deltas (+9 on MigrateAutoconfigurePackages, +15 on MigrateToModularStarters) are the regenerated totals reflecting the new entries added here, not manual edits.

Test plan

  • MigrateMongoDbModularStartersTest: imperative and reactive test-starter addition, negative cases for both (no starter added without matching test-slice usage), auto-configuration class renames, actuator package moves

@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Jul 17, 2026
@Kyran121
Kyran121 force-pushed the migrate-mongodb-modular-starters branch from 889dd45 to f4719c9 Compare July 18, 2026 13:35
@Kyran121
Kyran121 force-pushed the migrate-mongodb-modular-starters branch from f4719c9 to 16ab35c Compare July 18, 2026 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant