Spring Boot
Spring Boot is an extension of the
Spring Framework designed to cut through
complexities of spring framework.
Similar to fastAPI, its very easy and fast to run web application
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication // 1. Tells Spring Boot this is the main configuration class
@RestController // 2. Tells Spring this class will handle web requests
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args); // 3. Launches the embedded tomcat HTTP server and starts the app instantly!
}
@GetMapping("/hello") // 4. REST Endpoint "/hello"
public String sayHello(@RequestParam(value = "name", defaultValue = "World") String name) {
return String.format("Hello, %s!", name);
}
}
@SpringBootApplication
combines configuration, auto-configuration,
and component scan.
@RestController is part of Spring MVC.
Running main() starts an
embedded Tomcat server.
Spring Framework
To achieve the exact same web endpoint using the pure Spring Framework
(without Spring Boot), you have to configure everything manually that
Spring Boot usually does under the hood.
1. Manually configure a Spring
IoC container (using XML files or Java
@Configuration classes).
2. Set up a
DispatcherServlet (Spring's
front controller that intercepts web requests).
3. Deploy your application to an external
Servlet Container / Web Server
(like Apache Tomcat, Jetty, or WildFly) because pure Spring doesn't ship
with an embedded server.
The Controller (Same as Spring Boot)
|
Web Configuration (Replacing Spring Boot's
Auto-Config)
Uses @Configuration,
@ComponentScan, and
auto-configuration
equivalents.
|
Initializing the
Servlet Container
(Replacing main and Embedded Tomcat)
Implements
WebApplicationInitializer,
creates an
ApplicationContext, and
registers the
DispatcherServlet.
|
Spring Framework vs Spring Boot
| Aspect | Spring Framework | Spring Boot |
|---|---|---|
| What it is | Core framework: IoC container, DI, Spring MVC, Data, Security, AOP, and other modules. The foundation everything else builds on. | Extension on top of Spring Framework. Adds auto-configuration, starters, embedded servers, and production-ready defaults. |
| Configuration | Manual: XML, @Configuration classes, WebApplicationInitializer, explicit bean definitions, servlet setup. | Convention over configuration. @SpringBootApplication + application.yml; override only what you need. |
| Web server | No embedded server. Package as WAR and deploy to external Tomcat, Jetty, or WildFly (servlet container). |
Embedded Tomcat/Jetty/Undertow included. Run as executable JAR with
java -jar app.jar.
|
| Dependencies | You pick and align JAR versions yourself (Spring, Hibernate, Jackson, servlet API, etc.) — easy to get conflicts. |
Starters (e.g.
spring-boot-starter-web) pull in tested, compatible
versions via the Boot BOM.
|
| Boilerplate to run “Hello World” REST | Controller + web config + DispatcherServlet registration + external server install/deploy (see examples above). |
One class with
@SpringBootApplication,
@RestController, and main() — server
starts on run.
|
| Database setup | Manually define DataSource, EntityManagerFactory, transaction manager, and JPA properties as beans. |
Add spring-boot-starter-data-jpa
(starter) + JDBC URL in
application.properties;
Boot auto-configures the
rest.
|
| Operations / production | You add monitoring, health checks, and metrics yourself or via separate libraries. |
Spring Boot Actuator —
/health, metrics, info;
profiles for dev/test/prod out of
the box.
|
| Flexibility vs speed | Maximum control over every bean and servlet detail. More setup work. | Sensible defaults; less control until you exclude auto-config or define custom beans. Much faster to start. |
| Typical use today | Legacy WAR apps, fine-grained control, integrating Spring into an existing non-Boot codebase. | New REST APIs, microservices, cloud/Kubernetes deployments, and most greenfield Java backends. |
| Learning curve | Must understand servlets, application context, and manual wiring before the app runs. | Easier entry; still need to learn Spring concepts (beans, DI, MVC) but skip low-level server plumbing initially. |
See Terms.html for full definitions of every linked concept above.