Spring Boot
Spring Boot is an opinionated way to build a Spring application. It auto-configures a web server, JSON, and data sources from the classpath and application.properties, so you start with a runnable jar.
Detailed Explanation
Classic Spring needed many XML or @Configuration classes to stand up Tomcat, Jackson, and a DataSource. Boot looks at what you depend on (spring-boot-starter-web) and creates those beans unless you replace them. @SpringBootApplication is @Configuration plus component scan plus auto-configuration.
You still write Spring: @RestController, @Service, @Repository, constructor injection. Boot adds starters, an embedded server, actuator endpoints, and a fat jar (java -jar app.jar). Profiles (application-prod.yml) switch config. application.properties keys are documented in the appendix; random keys do nothing.
Auto-configuration is conditional (@ConditionalOnClass, @ConditionalOnMissingBean). If you define your own ObjectMapper bean, Boot backs off. debug=true or the conditions report shows why a bean appeared.
You reach for Boot when you are building a service on the Spring ecosystem. You reach for plain Spring or Micronaut/Quarkus when you want a different trade. You do not need Boot to learn servlets; you need it to ship a typical 2020s Java API.
The cost of magic is a context that fails at startup with a long condition report. Read it. The cost of a fat jar is size. The cost of component-scanning the whole world is slow tests; slice the package. The cost of default H2 in tests plus a real Postgres in prod is SQL that only works on one dialect; use Testcontainers.
Parent POM spring-boot-starter-parent manages versions. Do not mix Spring versions by hand.
Boot is a default graph, not a rule that you cannot write configuration. When auto-config fights you, define the bean you want and move on. Read spring-configuration-metadata.json or the docs for a property before inventing one. A property that is ignored fails silently. Actuator's health and info are how operators see the process; lock them down in production. The fat jar is a deployment unit. It does not replace thinking about connections, pools, and JSON contracts.
Code Examples
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
@RestController
class Health {
@GetMapping("/health")
String health() {
return "ok";
}
}import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
class PortInfo {
PortInfo(@Value("${server.port:8080}") int port) {
System.out.println(port);
}
}Common Gotchas
A missing starter means missing auto-config
no web starter, no Tomcat.
Your bean of the same type usually wins
Boot's `@ConditionalOnMissingBean` backs off.
Component scan defaults to the package of the `@SpringBootApplication` class
put it in the root package.