Category: java
What is Auto Configuration?
Published on 24 Jul 2026
Explanation
Auto Configuration is a Spring Boot feature that automatically configures Spring beans based on the dependencies available in the project. It reduces manual configuration and allows developers to start building applications with minimal setup.
Code:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Explanation
Starter Projects are pre-configured dependency bundles that provide all the libraries required for a specific feature. Instead of adding multiple dependencies manually, developers include a single starter dependency.
Code:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
Explanation
When the application starts, Spring Boot checks the classpath, existing beans, and configuration properties. Based on these conditions, it automatically creates and configures required beans such as DataSource, DispatcherServlet, and ObjectMapper.
Code:
@EnableAutoConfiguration
@Configuration
public class AppConfig {
}
Explanation
Spring Boot provides starters for web applications, data access, security, validation, testing, and more. Each starter includes compatible library versions, eliminating dependency conflicts and simplifying project setup.
Code:
spring-boot-starter-web spring-boot-starter-data-jpa spring-boot-starter-security spring-boot-starter-test
Explanation
Although Spring Boot automatically creates beans, developers can override them by defining custom @Bean methods or providing application properties. This flexibility allows customization while still benefiting from auto-configuration.
Code:
@Configuration
public class AppConfig {
@Bean
public RestTemplate restTemplate() {
return new RestTemplate();
}
}