Difficulty: Beginner
What is the difference between Spring and Spring Boot, and why did Spring Boot become the default choice for new Java backends?
Let's start with the question that opens almost every Java interview in India, because a crisp answer here sets the tone for the next forty minutes. Spring Framework is a large toolkit built around one big idea: you should not create and wire your own objects, the container should do it for you. It gives you dependency injection, AOP, transaction management, Spring MVC for web, JDBC and ORM integration, and much more. Spring Boot is not a competitor to Spring. It is an opinionated layer on top that removes the setup pain of using Spring.
Think of Spring as a professional kitchen with every appliance available but nothing plugged in. Before cooking a single dish you have to choose a chef's knife, connect the gas, and decide the layout. Spring Boot is the same kitchen delivered with a ready meal kit: the appliances are already plugged in, sensible defaults are selected, and you can start cooking immediately. You can still rearrange anything, but you do not have to before serving your first customer.
In classic Spring, a web application needed a web.xml or a WebApplicationInitializer, a DispatcherServlet configuration, a view resolver, a data source bean, an entity manager factory, a transaction manager, and a WAR file deployed to an external Tomcat. Version compatibility between libraries was your problem too. Spring Boot fixes this with four things. First, starters, which are curated dependency bundles with tested versions. Second, auto-configuration, which looks at your classpath and creates beans for you. Third, an embedded server, so the application is a plain executable JAR started with java -jar. Fourth, production features such as Actuator, externalised configuration, and sensible logging defaults.
A very common trap is the claim that Boot replaces Spring. It does not. Under the hood your controllers, services, and transactions are still plain Spring features. If you understand the Spring core, Boot feels like magic that you can explain; if you skip the core, Boot feels like magic that you cannot debug. Interviewers at TCS or Infosys often follow up with what happens when auto-configuration does the wrong thing, and the answer is that you override it by defining your own bean, excluding the auto-configuration class, or setting a property.
Another point worth mentioning is convention over configuration. A property like server.port=9090 replaces a pile of XML. A spring-boot-starter-data-jpa dependency plus a database driver on the classpath is enough for Boot to create a DataSource, a JPA EntityManagerFactory, and a transaction manager, using the connection URL from your properties file. You write business code, not plumbing.
Finally, be honest about trade-offs. Boot hides a lot, which can make startup time and memory use harder to reason about, and the fat JAR is larger. For microservices and typical CRUD backends these costs are usually acceptable, which is why Boot dominates. In an interview, close with a one-line summary: Spring is the framework, Spring Boot is the fastest, most opinionated way to use it, with production-ready defaults out of the box.
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
@RestController
public class DemoApplication {
@GetMapping("/hello")
public String hello() {
return "Hello from Spring Boot";
}
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
No XML, no external Tomcat, no manual DispatcherServlet setup. The starter-web dependency plus this class is a complete web service.
Spring Framework, Spring Boot, Auto-configuration, Embedded Server