Careeroza
Spring vs Spring Boot
Same Engine, Less Setup
Spring Boot is not a replacement for Spring. It is Spring, with the setup work done for you. Compare what you had to do for a web API before and after Boot:
| Task | Classic Spring (before Boot) | Spring Boot |
|---|---|---|
| Project setup | pick and match dozens of library versions by hand | choose starters on start.spring.io; versions are managed |
| Configuration | XML files or many @Configuration classes | auto-configuration + application.properties |
| Web server | install Tomcat, build a WAR, deploy it | embedded Tomcat, run java -jar |
| JSON | register a message converter yourself | Jackson configured automatically |
| Health / metrics | write your own | Spring Boot Actuator |
| Time to "Hello API" | an hour or more | about five minutes |
Classic Spring XML (the old way)
<!-- applicationContext.xml : every object declared by hand -->
<beans xmlns="http://www.springframework.org/schema/beans">
<bean id="productRepository" class="com.shopease.ProductRepository"/>
<bean id="productService" class="com.shopease.ProductService">
<constructor-arg ref="productRepository"/>
</bean>
<!-- + DispatcherServlet in web.xml, view resolvers, Jackson converters, a WAR for Tomcat ... -->
</beans>Spring Boot (the modern way)
package com.shopease;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication // turns on component scanning + auto-configuration
public class ShopeaseApplication {
public static void main(String[] args) {
SpringApplication.run(ShopeaseApplication.class, args); // starts Spring + embedded Tomcat
}
}Tip: In interviews, say it like this: "Spring Boot = Spring Framework + auto-configuration + starters + embedded server + production features. It removes boilerplate, it does not replace Spring."