← All recipes
Moderne licensed

Migrate web.xml to WebApplicationInitializer

Recipe IDio.moderne.java.spring.framework.webxml.WebXmlToWebApplicationInitializer
Artifactio.moderne.recipe:rewrite-spring

Migrate web.xml to WebApplicationInitializer for Spring applications. This allows for programmatic configuration of the web application context, replacing the need for XML-based configuration. This recipe only picks up web.xml files located in the src/main/webapp/WEB-INF directory to avoid inference with tests. It creates a WebXmlWebAppInitializer class in src/main/java with respect to submodules if they contain java files. **If it finds an existing WebXmlWebAppInitializer, it skips the creation**.

Single recipeProprietary

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.spring.framework.webxml.WebXmlToWebApplicationInitializer

If the recipe isn’t available locally, install it with:

mod config recipes jar install io.moderne.recipe:rewrite-spring:0.39.0

Options

NameTypeDescription
useJakartaEEBooleanIf true, the recipe will migrate to Jakarta EE 9+ namespaces. If false, it will use the javax.servlet namespace. If not set, the recipe will auto-detect based on the Spring Framework version: Spring 6+ uses Jakarta EE, Spring 5.x and earlier uses javax.
e.g. true

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