Spring Framework VS Spring Boot

🌱 Spring Framework (Core Spring)

Spring is a powerful Java framework used to build enterprise-level applications.
It provides tools for:

  • Dependency Injection (IoC)
  • Aspect-Oriented Programming (AOP)
  • Web MVC
  • Data access (JDBC, JPA)
  • Security, Transactions, etc.

😓 The Problem?

  • You have to configure everything manually (XMLs, beans, dependencies).
  • Takes time to set up a project.
  • Complex for beginners.

🚀 Spring Boot

Spring Boot is a tool built on top of Spring that makes it faster and easier to build Spring-based applications.

✅ What It Adds:

  • Auto-configuration – No need to write complex XML or Java configs.
  • Embedded Servers – Run your app without setting up Tomcat manually.
  • Production-ready features – Health checks, metrics, logging, etc.
  • Starter dependencies – Bundled JARs so you don’t manually manage libraries.

📊 Side-by-Side Comparison

Feature Spring Spring Boot
Setup Manual (XML/Java Config) Auto-configured, faster setup
Server Needs external server (Tomcat) Comes with embedded Tomcat
Dependencies Manually managed Uses starter dependencies
Focus Flexibility Convention over configuration
Learning Curve Steeper Beginner-friendly
Project Creation Slower Fast via Spring Initializr

 

🌱 Spring (Traditional Way)

🧾 1. XML Configuration (spring-config.xml)

<context:component-scan base-package="com.example"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"/>

🧑💻 2. Java Class (Controller)

@Controller
public class HelloController {
    @RequestMapping("/hello")
    @ResponseBody
    public String sayHello() {
        return "Hello, World";
    }
}

🌐 3. web.xml (Web Deployment Descriptor)

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring-config.xml</param-value>
    </init-param>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

🏁 4. Deploy to External Tomcat


🚀 Spring Boot (Modern Way)

🧑💻 1. Java Class (Controller + Main App)

@RestController
@SpringBootApplication
public class HelloApp {

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

    @GetMapping("/hello")
    public String sayHello() {
        return "Hello, World";
    }
}

 

✅ That’s it! No XML. No external server. Just run the app, and it works.


🔍 Key Differences

Aspect Spring Spring Boot
Setup Needs XML + web.xml No XML, just Java code
Deployment External server like Tomcat Embedded server (auto runs)
REST Controller @Controller + @ResponseBody @RestController
Main Class Not standard @SpringBootApplication
Run Command Manual WAR deployment java -jar app.jar


💡 Summary

  • Use Spring if you want full control and don’t mind writing configurations.
  • Use Spring Boot if you want to quickly build and deploy modern Java apps with minimal hassle.
Back to blog

Leave a comment