S

Spring Boot Handbook

Clean • Professional

Spring vs Spring Boot

1 minute

Spring vs Spring Boot

When learning Java, two names always come up: Spring Framework and Spring Boot. Both are powerful, but they serve different purposes. Here’s a simple and easy-to-understand comparison.

First, the Basics

Spring Framework (Spring)

A powerful and flexible Java framework used to build all types of applications — web, enterprise, cloud, batch processing, etc.

It provides:

  • Dependency Injection
  • Aspect-Oriented Programming
  • Spring MVC
  • Spring Security
  • Spring Data
  • Transaction management

But it requires manual configuration (XML or Java config), which increases setup time.


Spring Boot

A modern framework built on top of Spring to make development faster and easier.

It provides:

  • Auto-configuration
  • Starter dependencies
  • Embedded servers
  • Production-ready tools (Actuator)

Spring Boot removes boilerplate and handles setup automatically.

Spring = Buying raw ingredients and cooking everything yourself.

You control everything, but it takes time and effort.

Spring Boot = A ready-made meal kit.

Ingredients are pre-measured, partially prepared, and ready in minutes.


Key Differences

Feature / AspectSpring FrameworkSpring Boot
ConfigurationRequires manual configuration using XML or Java-based configAuto-configuration with smart defaults; minimal manual setup
Setup TimeLong setup (server config, beans, XML, dependencies)Very fast setup (starters + embedded server)
Dependency ManagementAdd and manage each dependency manuallyStarter dependencies bundle all required libraries
Server RequirementNeeds external server (Tomcat, Jetty, WebLogic)Comes with embedded servers (Tomcat, Jetty, Undertow)
Deployment TypeMostly WAR deploymentStandalone JAR: java -jar app.jar
Project StructureMore complex; multiple config filesSimple and consistent structure
Production FeaturesConfigure everything manuallyBuilt-in Actuator (health, metrics, monitoring)
Learning CurveSteep; requires understanding of multiple configsEasier due to opinionated defaults
FlexibilityHighly flexible; developer controls everythingConvention-over-configuration; less boilerplate
BootstrappingNeeds XML/Java config + context initializationNeeds only @SpringBootApplication
Performance TuningManual tuning requiredAuto-tuned defaults for many components
Use CasesEnterprise-level apps needing fine controlMicroservices, REST APIs, cloud-native apps
Project SizeSuitable for large monolithic systemsIdeal for small to medium microservices
Community Learning ResourcesLarge, but configuration-heavyEasier, more beginner-friendly
Build ToolsWorks with Maven/Gradle (manual setup)Maven/Gradle plugins auto-configure builds
Embedded ToolsNo built-in toolingDevTools, Actuator, embedded servers

Example — Building a Simple REST API

(A) Using Spring Framework (Old Way)

Steps:

  1. Configure DispatcherServlet in web.xml
  2. Create XML config for beans
  3. Set up external server (Tomcat)
  4. Create Controller
  5. Deploy WAR

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

@Controller
public class HelloController {
    @RequestMapping("/hello")
    @ResponseBody
    public String sayHello() {
        return "Hello from Spring!";
    }
}

Requires external Tomcat + WAR deployment.


(B) Using Spring Boot (Modern Way)

Steps:

  1. Add spring-boot-starter-web
  2. Write controller
  3. Run the app (embedded server)

Application

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

Controller

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

Run → Open http://localhost:8080/hello

No XML. No external server. No WAR.


When to Use What?

Use Spring (Framework) when:

  • You need full control over configuration
  • You’re working on legacy enterprise systems
  • You still deploy WAR files
  • You want modularity over convenience

Use Spring Boot when:

  • You build REST APIs, microservices
  • You want rapid development
  • You deploy to Docker/Kubernetes
  • You need production-ready features quickly

Conclusion

  • Spring = Powerful foundation (but configuration-heavy)
  • Spring Boot = Productivity booster (auto-config, embedded server, ready-to-run)

Spring is the engine.

Spring Boot is the entire car built around that engine.

Differences - Spring vs Spring Boot

learn code with durgesh images

Article 0 of 0