S

Spring Boot Handbook

Clean • Professional

Spring vs Spring Boot

1 minute

First, the Basics

  • Spring Framework (a.k.a Spring):
    A comprehensive framework for building Java applications.
    It provides dependency injection, aspect-oriented programming, data access, web MVC, security, etc.
    But it requires a lot of manual configuration.

  • Spring Boot:
    A framework built on top of Spring that makes development faster, easier, and less error-prone by removing configuration overhead.
    It comes with auto-configuration, starter dependencies, embedded servers, and production-ready features.

 

  • Spring = Buying raw ingredients and cooking everything yourself.

  • Spring Boot = Ordering a ready-made meal kit that comes pre-measured, half-cooked, and ready in 10 minutes.

Key Differences 

Feature / AspectSpring FrameworkSpring Boot
ConfigurationManual XML/Java config neededAuto-configuration (smart defaults)
Setup TimeLong (set up Tomcat, DataSource, beans manually)Short (starters + embedded server)
ServerRequires external server (Tomcat, Jetty, etc.)Comes with embedded Tomcat/Jetty/Undertow
DependenciesMust specify each libraryUses starter dependencies (bundled)
DeploymentTypically WAR file deploymentRun as a standalone JAR (java -jar app.jar)
Production FeaturesMust integrate manually (monitoring, metrics)Built-in via Spring Boot Actuator
Learning CurveSteeper (more boilerplate)Easier (opinionated defaults)
FocusFlexibility & modularityProductivity & convention-over-configuration
Use CaseLarge enterprise apps needing fine-grained controlMicroservices, REST APIs, cloud-native apps

Example — Building a Simple REST API

(A) Using Spring Framework

Steps:

  1. Configure DispatcherServlet in web.xml.

  2. Set up Spring Beans in applicationContext.xml.

  3. Configure Tomcat/Jetty server.

  4. Create Controller.

<!-- web.xml -->
<web-app>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>
<!-- web.xml -->
<web-app>
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>
@Controller
public class HelloController {
    @RequestMapping("/hello")
    @ResponseBody
    public String sayHello() {
        return "Hello from Spring!";
    }
}

Needs external Tomcat, WAR deployment.

(B) Using Spring Boot

Steps:

  1. Add spring-boot-starter-web dependency.

  2. Write Controller.

  3. Run the app.

@SpringBootApplication
public class HelloApp {
    public static void main(String[] args) {
        SpringApplication.run(HelloApp.class, args);
    }
}

@RestController
public class HelloController {
    @GetMapping("/hello")
    public String sayHello() {
        return "Hello from Spring Boot!";
    }
}

Just run → http://localhost:8080/hello works immediately. No XML. No server setup.

When to Use What?

  • Use Spring Framework when:

    • You need fine-grained control over every bean and configuration.

    • You’re working on large legacy enterprise systems that still follow WAR deployment.

    • You want flexibility over conventions.

  • Use Spring Boot when:

    • You want rapid development (REST APIs, microservices).

    • You’re deploying to cloud-native environments (Docker, Kubernetes).

    • You want production-ready features out of the box.

Conclusion

  • Spring = Foundation (powerful but configuration-heavy).

  • Spring Boot = Accelerator (removes boilerplate, adds auto-magic).

  • Spring Boot saves time, reduces errors, and is ideal for modern cloud-based apps.

  • Example proves: Boot = 5 lines of code vs. Spring = multiple XMLs + configs.

Think of Spring as the “engine” and Spring Boot as the “car”. You can build your own car from scratch with just the engine (Spring), but Boot gives you a ready-to-drive car.

Article 0 of 0