Hook: Spring Boot is the shortcut that turns a pile of Spring pieces into a running app with sensible defaults.
Question: What are the features of Spring Boot?
Answer: Spring Boot gives you starter dependencies, auto-configuration, embedded servers, externalized configuration, and production-ready tools like Actuator. It also reduces manual setup by choosing sensible defaults for things like web servers, logging, and application wiring. In simple words, it helps you build and run Spring apps faster with less boilerplate.
Interview-Ready Answer: Spring Boot features include starter dependencies, auto-configuration, embedded servers like Tomcat, externalized configuration, and production-ready support through Actuator. My mental model is that Spring Boot does the wiring and setup work for me, so I can focus on business code. A useful detail is that Boot can package the app as a standalone JAR, which makes deployment much simpler.
spring-boot-starter-web for REST APIs or spring-boot-starter-test for testing. The big win is version compatibility: Boot chooses a known-good set so you do not spend time matching library versions by hand.@ConditionalOnClass and @ConditionalOnMissingBean.application.properties, application.yml, environment variables, command-line arguments, or profile-specific files. This keeps the same binary usable in dev, test, and production./actuator/health and /actuator/metrics so ops teams can monitor the app. This is a practical feature, not just a framework feature.8080, and you can override that with server.port.| Area | Traditional Spring | Spring Boot |
|---|---|---|
| Setup | More manual | Mostly automatic |
| Dependencies | Pick many versions yourself | Use starters |
| Server | External app server often needed | Embedded server by default |
| Config | More explicit wiring | Sensible defaults + overrides |
| Ops | Add monitoring separately | Actuator built in |
O(N) for startup scanning rather than a heavy per-request penalty.jakarta.* namespaces, while Boot 2.x used javax.*.server.port=0.Memory-style summary: Spring Boot is not a different framework; it is Spring with the setup, server, and defaults already wired in.
Real-World Story: Imagine a checkout service in an e-commerce system. The team uses spring-boot-starter-web for REST APIs, Actuator for health checks, and externalized config for payment gateway URLs and timeouts. In Kubernetes, the app starts as a standalone JAR on port 8080, and ops can check /actuator/health before sending traffic.
Now the bug: one deployment accidentally used the wrong profile, so the health endpoint was not exposed and the app listened on a different port than the service expected. The symptoms were repeated pod restarts, Connection refused errors, and checkout requests timing out. From the user side, carts looked fine, but payment submission failed at peak traffic because the load balancer thought the app was unhealthy.
The lesson is simple: Spring Boot features are not just convenience; they are what make deployment predictable. Externalized configuration, embedded servers, and Actuator together prevent a lot of avoidable outages.
package com.example.bootfeatures;
import java.util.LinkedHashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class SpringBootFeaturesDemoApplication {
// Externalized configuration: if app.title is not set anywhere,
// Boot uses the default value below. This is one reason Boot is easy to run in every environment.
@Value("${app.title:Spring Boot Demo}")
private String appTitle;
public static void main(String[] args) {
// One line is enough because Boot auto-configures the application context and embedded server.
SpringApplication.run(SpringBootFeaturesDemoApplication.class, args);
}
@Bean
CommandLineRunner startupMessage() {
// This runs after the context starts, which is a simple way to prove the app booted.
return args -> System.out.println("Started " + appTitle + " successfully.");
}
@GetMapping("/hello")
public ResponseEntity<?> hello(@RequestParam(required = false) String name) {
// Edge case: blank input should not be treated as a valid user name.
// Returning 400 is better than silently producing a misleading response.
if (name == null || name.isBlank()) {
Map<String, Object> error = new LinkedHashMap<>();
error.put("error", "name query parameter is required");
error.put("example", "/hello?name=Anita");
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(error);
}
Map<String, Object> body = new LinkedHashMap<>();
body.put("app", appTitle);
body.put("message", "Hello, " + name + "!");
return ResponseEntity.ok(body);
}
}
Follow-up & Tricky Questions:
@SpringBootApplication and @EnableAutoConfiguration? @SpringBootApplication is a convenience annotation that combines component scanning, auto-configuration, and configuration support. In most apps you use it on the main class instead of adding the lower-level annotations one by one.server.port=9090 in properties or pass --server.port=9090 at startup. This is a classic example of externalized configuration overriding defaults.server.port=0 a random bug? No, it is intentional. It tells the OS to choose a free ephemeral port, which is very useful in tests and parallel runs.Tricky / gotcha questions:
server.port=0. Interviewers often check whether you know defaults are just defaults.Common Mistakes:
Memory Hook: Think of Spring Boot as a car that already has the engine, dashboard, and GPS installed. You do not build the car from scratch; you just turn the key and drive.
Cheat Sheet:
jakarta.*.Practice Tasks:
spring-boot-starter-web and verify it runs without an external server.app.title to application.properties and see how it changes the response without changing code.