Spring Boot learning path Level 2 This level · 4 of 11
Medium java spring

How did Spring Boot remove XML configuration almost completely?

The 30 second answer

Spring Boot didn't invent Java configuration; Spring Framework already had @Configuration, @Bean, @Import and component scanning. What Spring Boot adds is auto-configuration for common infrastructure, plus externalized settings bound with @ConfigurationProperties. An embedded server also removes the usual need for a web deployment descriptor. So most applications no longer need XML, but @ImportResource still lets me bring in existing XML configuration when migrating an older application.

Could you say this in an interview?

Classic Spring needed XML for three jobs. Each one has a replacement.

1. Declaring beans → Java config and scanning (Spring Framework).

@Configuration
class PaymentConfig {
    @Bean
    PaymentClient paymentClient(RestClient.Builder builder) {
        return new PaymentClient(builder.baseUrl("https://pay.example").build());
    }
}

@Configuration plus @Bean replaces <bean> elements, @Import replaces <import>, and @ComponentScan replaces <context:component-scan>.

2. Infrastructure beans → auto-configuration (Spring Boot). Before Spring Boot you declared a DataSource, a transaction manager, a DispatcherServlet, view resolvers and message converters yourself. Auto-configuration now creates them when the right classes are on the classpath, and backs off when you define your own.

3. Deployment descriptors → embedded server (Spring Boot). web.xml registered the DispatcherServlet and filters in an external container. With Spring Boot, the app starts its own embedded server. The DispatcherServlet is registered by DispatcherServletAutoConfiguration, and any Filter or Servlet bean is registered automatically.

4. Placeholders and property files → externalized config. <context:property-placeholder> is replaced by the Environment, which Spring Boot fills from application.properties/.yml, environment variables and arguments. @ConfigurationProperties binds them to typed objects:

@ConfigurationProperties("payments")
record PaymentProperties(URI baseUrl, Duration timeout) { }

XML is still possible:

@SpringBootApplication
@ImportResource("classpath:legacy-beans.xml")
class App { }

This is useful when migrating an old application step by step.

Interview distinction: Java config is a Spring Framework feature (since Spring 3.0). Spring Boot did not invent it. What Spring Boot removed is the need to write the infrastructure configuration at all.

Sources (3)
  1. Spring Framework reference: Java-based container configuration, basic conceptsdocs.spring.io
  2. Spring Boot reference: Configuration classes and importing XMLdocs.spring.io
  3. Spring Boot reference: Type-safe configuration propertiesdocs.spring.io
Previous
Next