Migrate PropertyMapper API for Spring Boot 4.0
io.moderne.java.spring.boot4.MigratePropertyMapperio.moderne.recipe:rewrite-springMigrates PropertyMapper usage to accommodate Spring Boot 4.0 behavioral changes. In Boot 4.0, PropertyMapper.from() no longer calls to() when the source value is null. This recipe first inserts .always() on bare chains to preserve null-passing behavior, then removes the now-redundant .whenNonNull() and .alwaysApplyingWhenNonNull() calls. Guarded by a Spring Boot < 4.0 precondition so that on subsequent recipe cycles (after the version is bumped by the parent migration recipe), this recipe becomes a no-op — preventing it from incorrectly adding .always() to chains that just had .whenNonNull() stripped.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe io.moderne.java.spring.boot4.MigratePropertyMapperIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-spring:0.39.0Definition
This recipe runs the following recipes in order.
- Preserve
PropertyMappernull-passing behaviorio.moderne.java.spring.boot4.InsertPropertyMapperAlwaysMethodInvocation - Remove method invocations
org.openrewrite.java.RemoveMethodInvocations - Remove method invocations
org.openrewrite.java.RemoveMethodInvocations
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats