Hackforge Academy

Category: java

Spring MVC vs Spring Boot

Published on 17 Mar 2026

Explanation

Spring MVC is a Java web framework used to build web applications using the Model-View-Controller design pattern. It separates application logic, user interface, and request handling.

Code:

@Controller
public class HelloController {

  @RequestMapping("/hello")
  public String hello(Model model) {
    model.addAttribute("message",
              "Hello from Spring MVC");
    return "hello";
  }
}

Explanation

Spring Boot is a framework built on top of Spring that simplifies application development by providing auto-configuration and embedded servers like Tomcat.

Code:

@RestController
public class HelloController {

  @GetMapping("/hello")
  public String hello() {
    return "Hello from Spring Boot";
  }
}

Explanation

The @SpringBootApplication annotation enables auto configuration, component scanning, and configuration support to quickly bootstrap a Spring Boot application.

Code:

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

Explanation

Spring Boot provides starter dependencies like spring-boot-starter-web which automatically include libraries required to build web applications.

Code:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>
    spring-boot-starter-web
  </artifactId>
</dependency>

Explanation

In Spring MVC, @RequestMapping maps HTTP requests to controller methods, allowing developers to define URL endpoints easily.

Code:

@RequestMapping("/users")
public String users() {
  return "users";
}

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community