wasAsked.

What is the difference between Spring and Spring Boot?

Frequently Asked (All Companies) · Role not specified · technical

Published

Year not specified · Java, Spring Boot

Community answers

Posted by wasAsked editorial collection

Spring Framework is the foundational Java framework providing dependency injection, AOP, data access, transactions and web MVC. Spring Boot is built on top of Spring and makes it much faster to create production-ready applications by providing auto-configuration, starter dependencies and an embedded server. Spring Framework - Core features: inversion of control and dependency injection (ApplicationContext, beans), aspect-oriented programming, transaction management, Spring MVC for web applications, JDBC templates, integration with JPA and Hibernate, testing support. - Traditionally required a lot of configuration: XML files or Java configuration classes for data sources, view resolvers, transaction managers and component scanning. - Applications were usually packaged as WAR files and deployed to an external server such as Tomcat. Spring Boot - An opinionated extension of Spring that removes most of the boilerplate. - Auto-configuration: based on the libraries on the classpath and your properties, Spring Boot configures beans automatically (for example, adding spring-boot-starter-data-jpa plus a database driver configures a DataSource, EntityManagerFactory and transaction manager). - Starters: curated dependency sets (spring-boot-starter-web, -data-jpa, -security, -test) with compatible versions managed for you. - Embedded servers: Tomcat (default), Jetty or Undertow inside the application, so you run it as a standalone executable JAR: java -jar app.jar. - Externalised configuration: application.properties or application.yml, profiles, environment variables. - Production features: Spring Boot Actuator for health checks, metrics and info endpoints; easy integration with Micrometer and observability tools. - Developer tools: DevTools for live reload, Spring Initializr (start.spring.io) to generate projects. Minimal Spring Boot application: @SpringBootApplication public class OrdersApplication { public static void main(String[] args) { SpringApplication.run(OrdersApplication.class, args); } } @RestController @RequestMapping("/api/orders") class OrderController { @GetMapping("/{id}") OrderDto get(@PathVariable long id) { return new OrderDto(id, "PAID"); } } The same in plain Spring would require configuring a DispatcherServlet, component scanning, JSON message converters and a servlet container. Key differences - Configuration: manual in Spring vs automatic with sensible defaults in Spring Boot (still overridable). - Dependencies: you choose compatible versions yourself in Spring; Spring Boot manages them through starters and its dependency management. - Deployment: external server and WAR in classic Spring; embedded server and executable JAR (or container image) in Spring Boot. - Production readiness: Spring Boot includes Actuator and externalised configuration out of the box. - Learning curve: Spring Boot is much faster to start with, though understanding core Spring helps when you need to customise. Relationship: Spring Boot is not a replacement for Spring — it uses the Spring Framework underneath. Today almost all new Spring projects use Spring Boot, especially for microservices with Spring Cloud.

Ravindra Wadile · · 0 likes

Sign in to add your answer

Related interview topics