Migrate to Spring Batch 5.0 from 4.3
Recipe ID
org.openrewrite.java.spring.batch.SpringBatch4To5MigrationArtifactorg.openrewrite.recipe:rewrite-springMigrate applications built on Spring Batch 4.3 to the latest Spring Batch 5.0 release.
Composite recipespringbatchMSAL
Add to your build
Get a download tokenThis recipe is Moderne licensed, so the token must belong to a Moderne customer. It replaces YOUR_DOWNLOAD_TOKEN below.
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("org.openrewrite.java.spring.batch.SpringBatch4To5Migration")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("org.openrewrite.recipe:rewrite-spring:6.40.0")
}
Then run
./gradlew rewriteRunUsage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.spring.batch.SpringBatch4To5MigrationIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-spring:RELEASEDefinition
This recipe runs the following recipes in order.
- Upgrade Gradle or Maven dependency versions
org.openrewrite.java.dependencies.UpgradeDependencyVersion - Transform classes that extend
*ListenerSupportto implement the*Listenerinterfaces insteadorg.openrewrite.java.spring.batch.ListenerSupportClassToInterface - Migrate
JobBuilderFactorytoJobBuilderorg.openrewrite.java.spring.batch.MigrateJobBuilderFactory - Migrate
StepBuilderFactorytoStepBuilderorg.openrewrite.java.spring.batch.MigrateStepBuilderFactory - Add
PlatformTransactionManagertotasklet()andchunk()callsorg.openrewrite.java.spring.batch.AddTransactionManagerToTaskletAndChunk - Migrate
ItemWriterorg.openrewrite.java.spring.batch.MigrateItemWriterWrite - Remove
DefaultBatchConfigurerorg.openrewrite.java.spring.batch.RemoveDefaultBatchConfigurer - Change the type of
skipCountparameter inSkipPolicyfrominttolongorg.openrewrite.java.spring.batch.UpgradeSkipPolicyParameterType - Change type
org.springframework.batch.core.metrics.BatchMetricstoorg.springframework.batch.core.observability.BatchMetricsorg.openrewrite.java.ChangeType - Change type
org.springframework.batch.core.step.item.Chunktoorg.springframework.batch.item.Chunkorg.openrewrite.java.ChangeType - Change type
org.springframework.batch.core.configuration.annotation.ScopeConfigurationtoorg.springframework.batch.core.configuration.support.ScopeConfigurationorg.openrewrite.java.ChangeType - Convert receive type in some invocation of StepExecution.xx()
org.openrewrite.java.spring.batch.ConvertReceiveTypeWhenCallStepExecutionMethod - Migrate
DatetoLocalDateTimefor Spring Batch timestamp methodsorg.openrewrite.java.spring.batch.MigrateStepExecutionTimestampTypes - Migration invocation of JobParameter.toString to JobParameter.getValue.toString
org.openrewrite.java.spring.batch.JobParameterToString - Add class argument to
JobParametersorg.openrewrite.java.spring.batch.MigrateJobParameter - Migrate method when it annotated by Spring Batch API
org.openrewrite.java.spring.batch.MigrateMethodAnnotatedByBatchAPI - Change type
JobRegistryBeanPostProcessortoJobRegistrySmartInitializingSingletonorg.openrewrite.java.ChangeType
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