Definition
Preconditions1
Recipes143
- Add managed Maven dependency
- Migrate to Spring Boot 3.5
- Convert auto-configuration
excludetoexcludeName - Upgrade to Spring Cloud 2025.1
- Migrate from
spring-cloud-contract-wiremocktowiremock-spring-boot - Remove
@Beanmethods for modules built-in to Jackson 3 - Migrate to Spring Framework 7.0
- Migrate to Spring Security 7.0
- Migrate to Spring Batch 6.0 from 5.2
- Use constructor injection for
StoredProcedureItemReader - Add comment to method invocations
- Add comment to method invocations
- Change type
- Change type
- Add
setJobRegistry(..)to manually configuredTaskExecutorJobOperator - Add
@EnableJdbcJobRepositoryalongside@EnableBatchProcessing - Flag deprecated
ChunkListenercallbacks for manual migration toChunkListener<I, O> - Migrate Spring Boot properties to 4.0
- Replace
@MockBeanand@SpyBean - Migrate to Hibernate 7.2.x
- Migrate to testcontainers-java 2.x
- Upgrade to SpringDoc 3.0
- Migrate to Spring for GraphQL 2.0
- Upgrade Gradle or Maven dependency versions
- Upgrade Gradle or Maven dependency versions
- Upgrade Maven plugin version
- Upgrade Maven parent project version
- Update a Gradle plugin by id
- Update Gradle wrapper
- Update a Gradle plugin by id
- Upgrade Maven plugin version
- Upgrade Gradle or Maven dependency versions
- Migrate
@AutoConfigureMockMvcHtmlUnit attributes to nested@HtmlUnit - Co-exclude
UserDetailsServiceAutoConfigurationwhereSecurityAutoConfigurationis excluded - Expand split
spring.autoconfigure.excludeentries for Spring Boot 4.0 - Replace deprecated RequestMatcherProvider with new API
- Add Spring Boot 4.0 modular starter dependencies
- Migrate to Spring Boot 4.0 modular starters
- Migrate packages to modular starters
- Rename Spring Boot 4.0 starters with managed versions
- Change Gradle or Maven dependency
- Change Gradle or Maven dependency
- Change Gradle or Maven dependency
- Change Gradle or Maven dependency
- Change Gradle or Maven dependency
- Remove a Gradle or Maven dependency
- Change Gradle or Maven dependency
- Upgrade Gradle or Maven dependency versions
- Upgrade Gradle or Maven dependency versions
- Change Gradle or Maven dependency
- Upgrade Gradle or Maven dependency versions
- Add
@AutoConfigureTestRestTemplateif necessary - Add
@AutoConfigureWebTestClientif necessary - Spring Security 7 modularization
- Sync Gradle ext properties with BOM
- Upgrade Gradle or Maven dependency versions
- Migrate Spring Cloud AWS (awspring) to 4.0
- Migrate Spring Cloud Azure to 7.x
- Upgrade MyBatis to Spring Boot 4.0
- Migrate Spring Retry to Spring Resilience
- Add explicit version for REST Assured
- Migrate to Spring HATEOAS 3.0
- Migrate to Spring WS 5.0
- Change type
- Find and replace
- Change type
- Find and replace
- Change type
- Find and replace
- Change type
- Find and replace
- Change type
- Find and replace
- Change type
- Find and replace
- Change type
- Find and replace
- Migrate to Jakarta EE 11
- Migrate to JSpecify
- Change type
- Change type
- Migrate from Elasticsearch 8 to 9
- Migrate to Kafka 4.1
- Migrate
DefaultResponseErrorHandler.handleErrormethod signature - Migrate
handleErrormethod invocations to new signature - Remove path extension content negotiation methods
- Migrate deprecated path mapping options
- Remove deprecated
setPathMatcher()calls - Migrate
HttpHeadersmethods removed whenMultiValueMapcontract was dropped - Add
@MockitoSettings(strictness = Strictness.LENIENT)for@MockitoBeantests - Add
@AutoConfigureMockMvcto@SpringBootTestclasses usingMockMvc - Add MongoDB representation properties for UUID and BigDecimal
- Replace deprecated
org.springframework.boot.autoconfigure.mongoAPI - Replace deprecated
DockerApi - Replace deprecated
ThreadPoolTaskSchedulerBuilderconstructor - Replace removed
RedisCacheConfiguration.getTtl() - Remove
HttpMessageConvertersAutoConfigurationreferences - Migrate
PropertyMapperAPI for Spring Boot 4.0 - Add
useDefaultJaasConfig=trueto MSSQL Kerberos JDBC URLs - Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Replace Kotlin property assignment with setter call
- Change type
- Find and replace
- Change type
- Change type
- Flag deprecated ReactorNettyHttpClientMapper for migration
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Change type
- Rename Maven property key
- Change a Gradle plugin version by id
- Rename package name
- Rename package name
- Change type
- Change type
- Add
spring-boot-starter-validationdependency - Add Jackson2 for Jersey using JSON
- Adopt Jackson 3
- Migrate
JsonFactoryDecoratortoTokenStreamFactoryBuilderDecorator - Remove
ContentNegotiationConfigurer.favorPathExtension()calls - Migrate Spring Session Hazelcast to Hazelcast Spring Session
- Remove Spring Pulsar Reactive support
- Remove
ZipkinAutoConfiguration - Remove
SslBundlesparameter fromKafkaPropertiesbuild methods - Read servlet web server factory settings through
getSettings() - Spring Boot 4.0 Module Starter Relocations
- Remove redundant explicit dependencies and versions
- Remove redundant explicit dependency and plugin versions
- Remove
loaderImplementationfrom Gradle - Remove XML tag
Examples
java, java, java
- java
- Diff
import org.springframework.boot.BootstrapContext;
import org.springframework.boot.BootstrapContextClosedEvent;
class A {
void configure(BootstrapContext context, BootstrapContextClosedEvent event) {}
}
import org.springframework.boot.bootstrap.BootstrapContext;
import org.springframework.boot.bootstrap.BootstrapContextClosedEvent;
class A {
void configure(BootstrapContext context, BootstrapContextClosedEvent event) {}
}
@@ -1,2 +1,2 @@
-import org.springframework.boot.BootstrapContext;
-import org.springframework.boot.BootstrapContextClosedEvent;
+import org.springframework.boot.bootstrap.BootstrapContext;
+import org.springframework.boot.bootstrap.BootstrapContextClosedEvent;
- java
- Diff
import org.springframework.boot.BootstrapRegistry;
import org.springframework.boot.BootstrapRegistryInitializer;
class B {
void configure(BootstrapRegistry registry, BootstrapRegistryInitializer initializer) {}
}
import org.springframework.boot.bootstrap.BootstrapRegistry;
import org.springframework.boot.bootstrap.BootstrapRegistryInitializer;
class B {
void configure(BootstrapRegistry registry, BootstrapRegistryInitializer initializer) {}
}
@@ -1,2 +1,2 @@
-import org.springframework.boot.BootstrapRegistry;
-import org.springframework.boot.BootstrapRegistryInitializer;
+import org.springframework.boot.bootstrap.BootstrapRegistry;
+import org.springframework.boot.bootstrap.BootstrapRegistryInitializer;
- java
- Diff
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.DefaultBootstrapContext;
class C {
void configure(ConfigurableBootstrapContext configurableContext, DefaultBootstrapContext defaultContext) {}
}
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
import org.springframework.boot.bootstrap.DefaultBootstrapContext;
class C {
void configure(ConfigurableBootstrapContext configurableContext, DefaultBootstrapContext defaultContext) {}
}
@@ -1,2 +1,2 @@
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.DefaultBootstrapContext;
+import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
+import org.springframework.boot.bootstrap.DefaultBootstrapContext;
java
- java
- Diff
import org.springframework.boot.env.EnvironmentPostProcessor;
class MyConfig {
void configure(EnvironmentPostProcessor processor) {
}
}
import org.springframework.boot.EnvironmentPostProcessor;
class MyConfig {
void configure(EnvironmentPostProcessor processor) {
}
}
@@ -1,1 +1,1 @@
-import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.boot.EnvironmentPostProcessor;
java
- java
- Diff
import org.springframework.batch.core.repository.ExecutionContextSerializer;
import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
class BatchConfig {
ExecutionContextSerializer serializer() {
return new Jackson2ExecutionContextStringSerializer();
}
}
import org.springframework.batch.core.repository.ExecutionContextSerializer;
import org.springframework.batch.core.repository.dao.JacksonExecutionContextStringSerializer;
class BatchConfig {
ExecutionContextSerializer serializer() {
return new JacksonExecutionContextStringSerializer();
}
}
@@ -2,1 +2,1 @@
import org.springframework.batch.core.repository.ExecutionContextSerializer;
-import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
+import org.springframework.batch.core.repository.dao.JacksonExecutionContextStringSerializer;
@@ -6,1 +6,1 @@
class BatchConfig {
ExecutionContextSerializer serializer() {
- return new Jackson2ExecutionContextStringSerializer();
+ return new JacksonExecutionContextStringSerializer();
}
java
- java
- Diff
import org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksObservabilityAutoConfiguration;
class A {
void configure(ScheduledTasksObservabilityAutoConfiguration config) {}
}
import org.springframework.boot.micrometer.observation.autoconfigure.ScheduledTasksObservationAutoConfiguration;
class A {
void configure(ScheduledTasksObservationAutoConfiguration config) {}
}
@@ -1,1 +1,1 @@
-import org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksObservabilityAutoConfiguration;
+import org.springframework.boot.micrometer.observation.autoconfigure.ScheduledTasksObservationAutoConfiguration;
@@ -4,1 +4,1 @@
class A {
- void configure(ScheduledTasksObservabilityAutoConfiguration config) {}
+ void configure(ScheduledTasksObservationAutoConfiguration config) {}
}
java
- java
- Diff
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
class BatchConfig {
JobLauncher jobLauncher(JobRepository jobRepository) throws Exception {
TaskExecutorJobLauncher launcher = new TaskExecutorJobLauncher();
launcher.setJobRepository(jobRepository);
launcher.afterPropertiesSet();
return launcher;
}
}
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.launch.support.TaskExecutorJobOperator;
import org.springframework.batch.core.repository.JobRepository;
class BatchConfig {
JobOperator jobLauncher(JobRepository jobRepository, JobRegistry jobRegistry) throws Exception {
TaskExecutorJobOperator launcher = new TaskExecutorJobOperator();
launcher.setJobRegistry(jobRegistry);
launcher.setJobRepository(jobRepository);
launcher.afterPropertiesSet();
return launcher;
}
}
@@ -1,2 +1,3 @@
-import org.springframework.batch.core.launch.JobLauncher;
-import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher;
+import org.springframework.batch.core.configuration.JobRegistry;
+import org.springframework.batch.core.launch.JobOperator;
+import org.springframework.batch.core.launch.support.TaskExecutorJobOperator;
import org.springframework.batch.core.repository.JobRepository;
@@ -6,2 +7,3 @@
class BatchConfig {
- JobLauncher jobLauncher(JobRepository jobRepository) throws Exception {
- TaskExecutorJobLauncher launcher = new TaskExecutorJobLauncher();
+ JobOperator jobLauncher(JobRepository jobRepository, JobRegistry jobRegistry) throws Exception {
+ TaskExecutorJobOperator launcher = new TaskExecutorJobOperator();
+ launcher.setJobRegistry(jobRegistry);
launcher.setJobRepository(jobRepository);
java, java, java
- java
- Diff
import org.springframework.boot.BootstrapContext;
import org.springframework.boot.BootstrapContextClosedEvent;
class A {
void configure(BootstrapContext context, BootstrapContextClosedEvent event) {}
}
import org.springframework.boot.bootstrap.BootstrapContext;
import org.springframework.boot.bootstrap.BootstrapContextClosedEvent;
class A {
void configure(BootstrapContext context, BootstrapContextClosedEvent event) {}
}
@@ -1,2 +1,2 @@
-import org.springframework.boot.BootstrapContext;
-import org.springframework.boot.BootstrapContextClosedEvent;
+import org.springframework.boot.bootstrap.BootstrapContext;
+import org.springframework.boot.bootstrap.BootstrapContextClosedEvent;
- java
- Diff
import org.springframework.boot.BootstrapRegistry;
import org.springframework.boot.BootstrapRegistryInitializer;
class B {
void configure(BootstrapRegistry registry, BootstrapRegistryInitializer initializer) {}
}
import org.springframework.boot.bootstrap.BootstrapRegistry;
import org.springframework.boot.bootstrap.BootstrapRegistryInitializer;
class B {
void configure(BootstrapRegistry registry, BootstrapRegistryInitializer initializer) {}
}
@@ -1,2 +1,2 @@
-import org.springframework.boot.BootstrapRegistry;
-import org.springframework.boot.BootstrapRegistryInitializer;
+import org.springframework.boot.bootstrap.BootstrapRegistry;
+import org.springframework.boot.bootstrap.BootstrapRegistryInitializer;
- java
- Diff
import org.springframework.boot.ConfigurableBootstrapContext;
import org.springframework.boot.DefaultBootstrapContext;
class C {
void configure(ConfigurableBootstrapContext configurableContext, DefaultBootstrapContext defaultContext) {}
}
import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
import org.springframework.boot.bootstrap.DefaultBootstrapContext;
class C {
void configure(ConfigurableBootstrapContext configurableContext, DefaultBootstrapContext defaultContext) {}
}
@@ -1,2 +1,2 @@
-import org.springframework.boot.ConfigurableBootstrapContext;
-import org.springframework.boot.DefaultBootstrapContext;
+import org.springframework.boot.bootstrap.ConfigurableBootstrapContext;
+import org.springframework.boot.bootstrap.DefaultBootstrapContext;
java
- java
- Diff
import org.springframework.boot.env.EnvironmentPostProcessor;
class MyConfig {
void configure(EnvironmentPostProcessor processor) {
}
}
import org.springframework.boot.EnvironmentPostProcessor;
class MyConfig {
void configure(EnvironmentPostProcessor processor) {
}
}
@@ -1,1 +1,1 @@
-import org.springframework.boot.env.EnvironmentPostProcessor;
+import org.springframework.boot.EnvironmentPostProcessor;
java
- java
- Diff
import org.springframework.batch.core.repository.ExecutionContextSerializer;
import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
class BatchConfig {
ExecutionContextSerializer serializer() {
return new Jackson2ExecutionContextStringSerializer();
}
}
import org.springframework.batch.core.repository.ExecutionContextSerializer;
import org.springframework.batch.core.repository.dao.JacksonExecutionContextStringSerializer;
class BatchConfig {
ExecutionContextSerializer serializer() {
return new JacksonExecutionContextStringSerializer();
}
}
@@ -2,1 +2,1 @@
import org.springframework.batch.core.repository.ExecutionContextSerializer;
-import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
+import org.springframework.batch.core.repository.dao.JacksonExecutionContextStringSerializer;
@@ -6,1 +6,1 @@
class BatchConfig {
ExecutionContextSerializer serializer() {
- return new Jackson2ExecutionContextStringSerializer();
+ return new JacksonExecutionContextStringSerializer();
}
java
- java
- Diff
import org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksObservabilityAutoConfiguration;
class A {
void configure(ScheduledTasksObservabilityAutoConfiguration config) {}
}
import org.springframework.boot.micrometer.observation.autoconfigure.ScheduledTasksObservationAutoConfiguration;
class A {
void configure(ScheduledTasksObservationAutoConfiguration config) {}
}
@@ -1,1 +1,1 @@
-import org.springframework.boot.actuate.autoconfigure.scheduling.ScheduledTasksObservabilityAutoConfiguration;
+import org.springframework.boot.micrometer.observation.autoconfigure.ScheduledTasksObservationAutoConfiguration;
@@ -4,1 +4,1 @@
class A {
- void configure(ScheduledTasksObservabilityAutoConfiguration config) {}
+ void configure(ScheduledTasksObservationAutoConfiguration config) {}
}
java
- java
- Diff
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher;
import org.springframework.batch.core.repository.JobRepository;
class BatchConfig {
JobLauncher jobLauncher(JobRepository jobRepository) throws Exception {
TaskExecutorJobLauncher launcher = new TaskExecutorJobLauncher();
launcher.setJobRepository(jobRepository);
launcher.afterPropertiesSet();
return launcher;
}
}
import org.springframework.batch.core.configuration.JobRegistry;
import org.springframework.batch.core.launch.JobOperator;
import org.springframework.batch.core.launch.support.TaskExecutorJobOperator;
import org.springframework.batch.core.repository.JobRepository;
class BatchConfig {
JobOperator jobLauncher(JobRepository jobRepository, JobRegistry jobRegistry) throws Exception {
TaskExecutorJobOperator launcher = new TaskExecutorJobOperator();
launcher.setJobRegistry(jobRegistry);
launcher.setJobRepository(jobRepository);
launcher.afterPropertiesSet();
return launcher;
}
}
@@ -1,2 +1,3 @@
-import org.springframework.batch.core.launch.JobLauncher;
-import org.springframework.batch.core.launch.support.TaskExecutorJobLauncher;
+import org.springframework.batch.core.configuration.JobRegistry;
+import org.springframework.batch.core.launch.JobOperator;
+import org.springframework.batch.core.launch.support.TaskExecutorJobOperator;
import org.springframework.batch.core.repository.JobRepository;
@@ -6,2 +7,3 @@
class BatchConfig {
- JobLauncher jobLauncher(JobRepository jobRepository) throws Exception {
- TaskExecutorJobLauncher launcher = new TaskExecutorJobLauncher();
+ JobOperator jobLauncher(JobRepository jobRepository, JobRegistry jobRegistry) throws Exception {
+ TaskExecutorJobOperator launcher = new TaskExecutorJobOperator();
+ launcher.setJobRegistry(jobRegistry);
launcher.setJobRepository(jobRepository);
Usage
Run this recipe
This recipe has no required configuration options. Users of Moderne can run it via the Moderne CLI.
You will need to have configured the Moderne CLI on your machine before you can run the following command.
mod run . --recipe io.moderne.java.spring.boot4.UpgradeSpringBoot_4_0
If the recipe is not available locally, then you can install it using:
RELEASE resolves to the newest release and LATEST to the newest build of any kind, including snapshots. Either one lets mod config recipes upgrade pull in later versions without editing this command; a pinned version stays where you put it.
- RELEASE
- LATEST
- Pinned version
mod config recipes jar install io.moderne.recipe:rewrite-spring:RELEASE
mod config recipes jar install io.moderne.recipe:rewrite-spring:LATEST
mod config recipes jar install io.moderne.recipe:rewrite-spring:0.45.0
Data tables
Maven metadata failures
org.openrewrite.maven.table.MavenMetadataFailuresAttempts to resolve maven metadata that failed.
mod study . --last-recipe-run \
--data-table org.openrewrite.maven.table.MavenMetadataFailures
| Column | Description |
|---|---|
| Group id | The groupId of the artifact for which the metadata download failed. |
| Artifact id | The artifactId of the artifact for which the metadata download failed. |
| Version | The version of the artifact for which the metadata download failed. |
| Maven repository | The URL of the Maven repository that the metadata download failed on. |
| Snapshots | Does the repository support snapshots. |
| Releases | Does the repository support releases. |
| Failure | The reason the metadata download failed. |
PowerMock tests disabled for manual migration
org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabledTests disabled because they use a PowerMock feature with no Mockito equivalent. Each row is an action item: rework the test so it does not reach into private members, then re-enable it.
mod study . --last-recipe-run \
--data-table org.openrewrite.java.testing.mockito.table.PowerMockTestsDisabled
| Column | Description |
|---|---|
| Source path | The path of the test source file. |
| Test class | The test class the disabled test belongs to. |
| Disabled element | The test method that was disabled, or the class name when the usage sits outside a test method and the whole class had to be disabled. |
| Scope | METHOD when a single test was disabled, CLASS when the whole test class was. |
| Reason | The PowerMock usage that cannot be migrated. |
Source files that had results
org.openrewrite.table.SourcesFileResultsSource files that were modified by the recipe run.
mod study . --last-recipe-run \
--data-table org.openrewrite.table.SourcesFileResults
| Column | Description |
|---|---|
| Source path before the run | The source path of the file before the run. null when a source file was created during the run. |
| Source path after the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Parent of the recipe that made changes | In a hierarchical recipe, the parent of the recipe that made a change. Empty if this is the root of a hierarchy or if the recipe is not hierarchical at all. |
| Recipe that made changes | The specific recipe that made a change. |
| Estimated time saving | An estimated effort that a developer to fix manually instead of using this recipe, in unit of seconds. |
| Cycle | The recipe cycle in which the change was made. |
Source files that had search results
org.openrewrite.table.SearchResultsSearch results that were found during the recipe run.
mod study . --last-recipe-run \
--data-table org.openrewrite.table.SearchResults
| Column | Description |
|---|---|
| Source path of search result before the run | The source path of the file with the search result markers present. |
| Source path of search result after run the run | A recipe may modify the source path. This is the path after the run. null when a source file was deleted during the run. |
| Result | The trimmed printed tree of the LST element that the marker is attached to. |
| Description | The content of the description of the marker. |
| Recipe that added the search marker | The specific recipe that added the Search marker. |
Source files that errored on a recipe
org.openrewrite.table.SourcesFileErrorsThe details of all errors produced by a recipe run.
mod study . --last-recipe-run \
--data-table org.openrewrite.table.SourcesFileErrors
| Column | Description |
|---|---|
| Source path | The file that failed to parse. |
| Recipe that made changes | The specific recipe that made a change. |
| Stack trace | The stack trace of the failure. |
Recipe performance
org.openrewrite.table.RecipeRunStatsStatistics used in analyzing the performance of recipes.
mod study . --last-recipe-run \
--data-table org.openrewrite.table.RecipeRunStats
| Column | Description |
|---|---|
| The recipe | The recipe whose stats are being measured both individually and cumulatively. |
| Source file count | The number of source files the recipe ran over. |
| Source file changed count | The number of source files which were changed in the recipe run. Includes files created, deleted, and edited. |
| Cumulative scanning time (ns) | The total time spent across the scanning phase of this recipe. |
| Max scanning time (ns) | The max time scanning any one source file. |
| Cumulative edit time (ns) | The total time spent across the editing phase of this recipe. |
| Max edit time (ns) | The max time editing any one source file. |