Migrate Dropwizard to Spring Boot 3
Recipe ID
io.moderne.java.dropwizard.boot.MigrateDropwizardToSpringBoot3Artifact
io.moderne.recipe:rewrite-dropwizardMigrate a Dropwizard application to Spring Boot 3. First applies the Dropwizard to Spring Boot 2.7 migration, then adds managed lifecycle and health check migrations on top.
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.dropwizard.boot.MigrateDropwizardToSpringBoot3If the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-dropwizard:0.5.6Definition
This recipe runs the following recipes in order.
- Migrate to Dropwizard 5.0.x from 4.x
io.moderne.java.dropwizard.MigrateToDropwizard5 - Change Maven managed dependency groupId, artifactId and optionally the version
org.openrewrite.maven.ChangeManagedDependencyGroupIdAndArtifactId - Change Gradle or Maven dependency
org.openrewrite.java.dependencies.ChangeDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Remove a Gradle or Maven dependency
org.openrewrite.java.dependencies.RemoveDependency - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Remove supertype by fully qualified name
io.moderne.java.dropwizard.boot.method.RemoveSuperTypeByType - Migrate Dropwizard
MultiPartBundleto Spring multipart configurationio.moderne.java.dropwizard.boot.bundle.MigrateMultiPartBundle - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Add annotation if target annotation exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfAnnotationExists - Remove supertype by fully qualified name
io.moderne.java.dropwizard.boot.method.RemoveSuperTypeByType - Change annotation attribute name
org.openrewrite.java.ChangeAnnotationAttributeName - Remove annotation attribute
org.openrewrite.java.RemoveAnnotationAttribute - Remove annotation attribute
org.openrewrite.java.RemoveAnnotationAttribute - Change type
org.openrewrite.java.ChangeType - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Remove a Gradle or Maven dependency
org.openrewrite.java.dependencies.RemoveDependency - Remove a Gradle or Maven dependency
org.openrewrite.java.dependencies.RemoveDependency - Add annotation if target annotation exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfAnnotationExists - Change type
org.openrewrite.java.ChangeType - Change type
org.openrewrite.java.ChangeType - JUnit Jupiter migration from JUnit 4.x
org.openrewrite.java.testing.junit5.JUnit4to5Migration - Replace Dropwizard rules with Spring Boot test configuration
io.moderne.java.dropwizard.boot.test.DropwizardRulesJUnit4ToSpringBoot - Convert Dropwizard test rule calls to RestTemplate
io.moderne.java.dropwizard.boot.test.TransformDropwizardRuleInvocations - Convert Mockito mock() to @MockBean
io.moderne.java.dropwizard.boot.test.MockitoVariableToMockBean - Inline lambda body from matched method invocations
io.moderne.java.dropwizard.boot.test.MethodLambdaExtractor - Add
@SpringBootTestto classes usingDropwizardAppExtensionio.moderne.java.dropwizard.boot.test.AddSpringBootTestForDropwizardAppExtension - Replace a method invocation with a reference to an annotated field
io.moderne.java.dropwizard.boot.test.ReplaceMethodInvocationWithAnnotatedField - Replace a method invocation with a reference to an annotated field
io.moderne.java.dropwizard.boot.test.ReplaceMethodInvocationWithAnnotatedField - Replace
DropwizardAppExtension.getConfiguration()with@Autowiredconfiguration fieldio.moderne.java.dropwizard.boot.test.ReplaceDropwizardConfigurationWithAutowired - Replace
DropwizardAppExtension.getApplication()with@Autowiredapplication fieldio.moderne.java.dropwizard.boot.test.ReplaceDropwizardApplicationWithAutowired - Remove class variables matching package filter
io.moderne.java.dropwizard.boot.general.RemoveVariablesByPackage - Change supertype
io.moderne.java.dropwizard.boot.method.ChangeSuperType - Remove supertype by fully qualified name
io.moderne.java.dropwizard.boot.method.RemoveSuperTypeByType - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Add lifecycle annotations to Dropwizard Managed methods
io.moderne.java.dropwizard.boot.lifecycle.MigrateManagedLifecycle - Remove elements from a method declaration
throwsclauseorg.openrewrite.java.RemoveMethodThrows - Remove elements from a method declaration
throwsclauseorg.openrewrite.java.RemoveMethodThrows - Remove supertype by fully qualified name
io.moderne.java.dropwizard.boot.method.RemoveSuperTypeByType - Add annotation if target supertype exists
io.moderne.java.dropwizard.boot.annotation.AddClassAnnotationIfSuperTypeExists - Migrate Dropwizard health check Result calls and wrap exceptions
io.moderne.java.dropwizard.boot.health.MigrateHealthCheckMethod - Change method access level
org.openrewrite.java.ChangeMethodAccessLevel - Remove elements from a method declaration
throwsclauseorg.openrewrite.java.RemoveMethodThrows - Change method name
org.openrewrite.java.ChangeMethodName - Transform classes that extend a given Class to implement the given Interface instead
org.openrewrite.java.spring.batch.ReplaceSupportClassWithItsInterface - Change type
org.openrewrite.java.ChangeType - Change property key
org.openrewrite.yaml.ChangePropertyKey - Change property key
org.openrewrite.yaml.ChangePropertyKey - Change property key
org.openrewrite.yaml.ChangePropertyKey - Change property key
org.openrewrite.yaml.ChangePropertyKey - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Comment out property
org.openrewrite.yaml.CommentOutProperty - Change type
org.openrewrite.java.ChangeType - Replace DataSourceFactory build chain with @Autowired DataSource
io.moderne.java.dropwizard.boot.datasource.RemoveDataSourceFactoryBuildChain - Remove Dropwizard lifecycle.manage() calls
io.moderne.java.dropwizard.boot.datasource.RemoveLifecycleManageCalls - Remove methods referencing specified package
io.moderne.java.dropwizard.boot.general.RemoveMethodsByPackage - Remove class variables matching package filter
io.moderne.java.dropwizard.boot.general.RemoveVariablesByPackage - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency - Change type
org.openrewrite.java.ChangeType - Remove class variables matching package filter
io.moderne.java.dropwizard.boot.general.RemoveVariablesByPackage - Replace
Jackson.newObjectMapper()withnew ObjectMapper().findAndRegisterModules()io.moderne.java.dropwizard.boot.jackson.ReplaceJacksonNewObjectMapper - Remove unnecessary
@Overrideannotationsio.moderne.java.dropwizard.boot.method.RemoveUnnecessaryOverride - Remove unused imports
org.openrewrite.java.RemoveUnusedImports - Add Gradle or Maven dependency
org.openrewrite.java.dependencies.AddDependency
Data tables
Structured output this recipe can produce.
- Maven metadata failuresAttempts to resolve maven metadata that failed.
org.openrewrite.maven.table.MavenMetadataFailures - 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