Add @EnableJdbcJobRepository alongside @EnableBatchProcessing
io.moderne.java.spring.batch.AddEnableJdbcJobRepositoryArtifactio.moderne.recipe:rewrite-springIn Spring Batch 6, @EnableBatchProcessing no longer configures a JDBC-based JobRepository on its own: the JDBC store configuration moved to a new @EnableJdbcJobRepository annotation, and a bare @EnableBatchProcessing now registers an in-memory ResourcelessJobRepository. This recipe adds @EnableJdbcJobRepository next to every @EnableBatchProcessing so JDBC-backed persistence is preserved, moving the JDBC-specific attributes (dataSourceRef, tablePrefix, etc.) to the new annotation, copying transactionManagerRef to it (kept on @EnableBatchProcessing as well), converting isolationLevelForCreate from its Spring Batch 5 String form to the Isolation enum, and dropping the removed lobHandlerRef attribute. Classes that already declare @EnableJdbcJobRepository or @EnableMongoJobRepository, and programmatic DefaultBatchConfiguration subclasses, are left unchanged. A non-literal isolationLevelForCreate value is left in place for manual migration.
Add to your build
~/.gradle/gradle.properties
codeGenomeUsername=you@example.com
codeGenomeToken=YOUR_DOWNLOAD_TOKEN
build.gradle.kts
plugins {
id("org.openrewrite.rewrite") version("latest.release")
}
rewrite {
activeRecipe("io.moderne.java.spring.batch.AddEnableJdbcJobRepository")
}
repositories {
mavenCentral()
maven {
url = uri("https://artifacts.codegenomeproject.org/maven")
credentials {
username = providers.gradleProperty("codeGenomeUsername").get()
password = providers.gradleProperty("codeGenomeToken").get()
}
}
}
dependencies {
rewrite("io.moderne.recipe:rewrite-spring:0.42.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 io.moderne.java.spring.batch.AddEnableJdbcJobRepositoryIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-spring:RELEASEData 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