Spring Data 2025.1
When upgrading to Spring Data 2025.1, refer to the Spring Data 2025.1 Release Notes for newly introduced APIs, deprecated APIs, and breaking changes. Spring Data 2025.1 is the release train for Spring Boot 4.0, and the Spring Boot 4.0 upgrade recipe chains this recipe.
The io.arconia.rewrite.spring.data2025.UpgradeSpringData_2025_1 recipe automates the mechanical changes introduced in Spring Data 2025.1. You can use it to update your project to the latest Spring Data 2025.1.x release train.
The recipe will:
-
Upgrade
org.springframework.data:spring-data-bomto the 2025.1.x release train, and each Spring Data module to its own release line within that train, such as 4.0.x for Spring Data Commons and JPA, 5.0.x for MongoDB and REST, 6.0.x for Elasticsearch, and 8.0.x for Neo4j. -
For Spring Data Commons: replace
@PersistenceConstructorwith@PersistenceCreator, movePropertyPath,PropertyReferenceException,TypeInformation, and the other relocated core types to the neworg.springframework.data.corepackage, and rename the constructor-oriented mapping methods to their creator-oriented successors, such asisConstructorArgumenttoisCreatorArgument,getRequiredLeafPropertytogetLeafProperty, andgetTargetRepositoryViaReflectiontoinstantiateClass. -
For Spring Data JPA: comment out the removed
spring.data.jpa.query.native.parserproperty, since the query enhancer is now selected through thequeryEnhancerSelectorattribute of@EnableJpaRepositories. -
For Spring Data JDBC: move
QueryMappingConfigurationto the conversion package. -
For Spring Data MongoDB: rewrite boolean
allowDiskUsevalues on the@Metaannotation to the string values the attribute now accepts. -
For Spring Data for Apache Cassandra: replace the legacy asynchronous templates and operations that returned
ListenableFuturewith theCompletableFuturebased ones, and replace the deprecated mapping context and session factory beans withCassandraMappingContextandCqlSessionFactoryBean.
Some changes in Spring Data 2025.1 are deliberately not automated. ListenableFuture support is gone, so asynchronous query methods and callers of the Cassandra asynchronous templates need to work with CompletableFuture. The SpEL evaluators and the query method evaluation context providers were replaced by the value expression infrastructure, CastUtils and the repository ClassUtils were removed, MongoDB dropped its JMX support, Spring Data Redis dropped MicrometerTracingAdapter in favor of the tracing built into Lettuce, and QuerydslJpaRepository gave way to the predicate executor. Spring Data Redis also renamed its Jackson 2 object reader and writer to Jackson2ObjectReader and Jackson2ObjectWriter and reused the old names for Jackson 3, which the Spring Framework 7.0 upgrade already moves you to, so the recipe leaves those names alone. Several defaults changed in ways that affect stored data or generated queries: MongoDB’s BigDecimal and UUID representations, R2DBC quoting all identifiers, Spring Data JDBC no longer wrapping exceptions, and Spring Data JPA deriving JPQL instead of Criteria queries. Review the release notes for the parts that apply to your application.
See its entry in the Recipe Catalog for the full list of recipes this upgrade applies, each with its options and a before/after example.
Run the Recipe
You can apply this recipe with any OpenRewrite-compatible tool. The tabs below show three of them: the Arconia CLI, the OpenRewrite Gradle plugin, and the OpenRewrite Maven plugin. See Running Recipes for a comparison of when to pick each one.
-
Arconia CLI
-
Gradle
-
Maven
arconia rewrite run --recipe-name io.arconia.rewrite.spring.data2025.UpgradeSpringData_2025_1
First, create an init.gradle file in your project root with the following content.
initscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath("org.openrewrite:plugin:latest.release")
}
}
rootProject {
plugins.apply(org.openrewrite.gradle.RewritePlugin)
dependencies {
rewrite("io.arconia.migrations:rewrite-spring:latest.release")
}
// Remove when project repositories are disabled
afterEvaluate {
if (repositories.isEmpty()) {
repositories {
mavenCentral()
}
}
}
configurations.named("rewrite") {
canBeConsumed = false
}
}
Then, run the following command.
./gradlew rewriteRun \
--init-script init.gradle \
--no-parallel \
-DactiveRecipe=io.arconia.rewrite.spring.data2025.UpgradeSpringData_2025_1
You can remove the init.gradle file afterwards.
./mvnw -U org.openrewrite.maven:rewrite-maven-plugin:run \
-Drewrite.recipeArtifactCoordinates=io.arconia.migrations:rewrite-spring:LATEST \
-Drewrite.activeRecipes=io.arconia.rewrite.spring.data2025.UpgradeSpringData_2025_1