Spring Boot API

Build production-ready REST services with Spring Boot.

Overview

Spring Boot removes most of the configuration from the Spring ecosystem. With starters and auto-configuration you can have a working REST API running in minutes, then add a database, security, validation and documentation as you grow.

It is the most common choice for Java microservices and back-ends for web and mobile applications.

Where it is used

  • Backends for web and mobile apps
  • Microservices
  • Integration APIs between systems
  • Cloud-ready services in containers

A minimal REST controller

@RestController
@RequestMapping("/api/students")
public class StudentController {

    private final StudentRepository repo;

    public StudentController(StudentRepository repo) {
        this.repo = repo;
    }

    @GetMapping
    public List<Student> all() {
        return repo.findAll();
    }

    @PostMapping
    public Student create(@Valid @RequestBody Student s) {
        return repo.save(s);
    }
}

What you will cover

The key topics and features of Spring Boot API

Starters & Auto-Configuration

Add a dependency and Spring Boot configures it for you.

REST Controllers

@RestController, request mapping, path variables and JSON responses.

DTOs & Validation

Keep your API clean and validate incoming data with Bean Validation.

Spring Data JPA

Repositories with almost no boilerplate for CRUD and queries.

Spring Security & JWT

Authenticate users and protect your endpoints.

Testing & OpenAPI

Test with JUnit/MockMvc and document with Swagger/OpenAPI.