Auto-configuration and starters
Spring Boot is Spring with opinions:
- Starters: one dependency pulls in a tested set of libraries (
spring-boot-starter-web,spring-boot-starter-data-jpa,-security,-validation,-actuator). - Auto-configuration: if a library is on the classpath and you haven't defined the bean yourself, Boot configures it for you, for example a DataSource from your
spring.datasource.*properties. - Embedded server: Tomcat by default, so you run the app with
java -jar app.jar. - Externalized configuration and Actuator for running in production.
@SpringBootApplication combines @Configuration, @EnableAutoConfiguration and @ComponentScan of the main class's package and everything below it.
Versions: Boot 3 (2022) requires Java 17 and the jakarta packages. Boot 4.0 (November 2025, on Spring Framework 7) splits auto-configuration into smaller modules and moves to Jackson 3. Boot 4.1 (June 2026) adds Spring gRPC support.
Example
@SpringBootApplication
public class JavaAtlasApplication {
public static void main(String[] args) {
SpringApplication.run(JavaAtlasApplication.class, args);
}
}
// How auto-configuration decides, simplified
@AutoConfiguration
@ConditionalOnClass(DataSource.class)
public class MyDataSourceAutoConfiguration {
@Bean
@ConditionalOnMissingBean // your own bean always wins
DataSource dataSource(DataSourceProperties props) {
return props.initializeDataSourceBuilder().build();
}
}Common mistake
Putting the main class in a sub-package such as com.app.config. Component scanning covers only that package and below, so controllers in com.app.web are never found.
Under the hood
Auto-configuration classes are listed in META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports and guarded by @Conditional... annotations. Start the app with --debug, or check Actuator's conditions endpoint, to see which ones matched and why. Exclude one with @SpringBootApplication(exclude = ...).
Check yourself
You define your own DataSource bean. Which one is used?
How this connects
Know these first
Part of Job-ready backend developer, Microservices and production.
Was this lesson helpful?
Finished reading? Mark it complete to track your progress.