DEV Community

Pratik280
Pratik280

Posted on

Production-Grade Spring Boot APIs — Part 1: Web, JPA & What Really Happens at Startup

Most Spring Boot tutorials teach you how to build an API.

Very few explain what actually happens when a production Spring Boot application starts — and why those internals matter when systems grow.

This article documents how we actually understand and use Spring Boot foundations in real projects, not demo apps.

This is Part 1 of a 3-part series on Production-Grade Spring Boot API Design, written from real backend experience.

What this post covers

  • Why spring-boot-starter-web exists

  • starter vs starter-web

  • ORM, JPA, Hibernate — without confusion

  • Why Spring Data JPA removes DAOs & JDBC

  • Spring Boot application lifecycle (startup to request handling)

  • How DispatcherServlet fits into the picture

spring-boot-starter-web is the dependency that turns a plain Java application into a web‑ready REST API server.

It provides:

  • Spring MVC

  • Embedded web server (Tomcat by default)

  • DispatcherServlet

  • JSON serialization / deserialization

You do not configure servlets, servers, or JSON converters manually.

In production systems, this starter removes boilerplate and enforces convention over configuration.

spring-boot-starter vs spring-boot-starter-web

  • spring-boot-starter

    • Core Spring features
    • Dependency Injection
    • Auto‑configuration
    • Logging (SLF4J + Logback)
  • spring-boot-starter-web

    • Everything above plus
    • Spring MVC
    • Embedded server
    • REST API support

In short:

starter-web = starter + web capabilities


2. ORM, JPA & Hibernate (Production clarity)

What is ORM?

ORM (Object Relational Mapping) is a technique that maps:

Java objects ⇄ Database tables

So instead of writing SQL, you work with Java objects.


JPA vs Hibernate (Interview‑safe explanation)

  • JPA

    • A specification (set of rules)
    • Defines annotations and interfaces
    • Does not generate SQL
  • Hibernate

    • An implementation of JPA
    • Generates SQL
    • Talks to the database

In Spring Boot, we write code using JPA, while Hibernate does the heavy lifting.


Why spring-boot-starter-data-jpa is critical

We never use JDBC directly in modern Spring Boot microservices.

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
Enter fullscreen mode Exit fullscreen mode

This starter:

  • Integrates Spring Data with JPA

  • Uses Hibernate internally

  • Provides repository abstractions

  • Handles transactions automatically

Result: We persist Java objects without writing SQL or DAO classes.


Repository abstraction (No DAO, No SQL)

public interface OrderRepository extends JpaRepository<OrderEntity, Long> {}
Enter fullscreen mode Exit fullscreen mode

What this line really means:

“Spring, create a ready‑made database layer for this entity.”

Spring Data JPA:

  • Generates implementation at runtime

  • Provides CRUD, pagination, sorting

  • Manages transactions

This is production‑grade abstraction, not magic.


3. Spring Boot Application Lifecycle (What really happens)

┌─────────────────────────────┐
│        main() method        │
│ SpringApplication.run()     │
└──────────────┬──────────────┘
               ↓
┌─────────────────────────────┐
│   ApplicationContext        │
│        created              │
└──────────────┬──────────────┘
               ↓
┌─────────────────────────────┐
│     Component Scan          │
│  (@Service, @Controller)    │
└──────────────┬──────────────┘
               ↓
┌─────────────────────────────┐
│        Bean Creation        │
└──────────────┬──────────────┘
               ↓
┌─────────────────────────────┐
│   Dependency Injection      │
└──────────────┬──────────────┘
               ↓
┌─────────────────────────────┐
│   Embedded Server Starts    │
└──────────────┬──────────────┘
               ↓
┌─────────────────────────────┐
│ DispatcherServlet Ready 🚀  │
└─────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

What matters in production

  • Spring controls object creation (IoC)

  • Dependencies are injected before usage

  • Controllers are mapped after server startup

Developers write business logic — Spring handles infrastructure.

This is Part 1 of a 3-part series on Production-Grade Spring Boot API Design.

👉 Part 2 focuses on clean code structure, controllers, services, DTOs, and dependency injection.

Top comments (0)