How to Build Microservices with Spring Boot and Spring Cloud
A practical guide to Spring Boot microservices covering service boundaries, Eureka discovery, Spring Cloud Gateway, RestClient calls and Resilience4j.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
A practical guide to Spring Boot microservices covering service boundaries, Eureka discovery, Spring Cloud Gateway, RestClient calls and Resilience4j.
Add per-client rate limiting to Spring Boot with a Bucket4j filter that returns 429 and Retry-After, and learn when to go distributed.
ETag identifies a version of a resource, enabling 304 Not Modified caching and safe updates with If-Match. Includes strong vs weak ETags and Spring Boot code.
Learn how ETag, If-None-Match and If-Match let a REST API return 304 Not Modified and block lost updates, with Spring Boot examples.
@GetMapping and @PostMapping are Spring MVC shortcuts for GET and POST handlers. See how they differ, how to bind input, and which status codes to return.
See how to version REST APIs in Spring Boot with path, parameter, header and media type strategies, and how Spring Boot 4 supports versioning natively.
@RequestMapping maps web requests to Spring MVC handler methods by path, method, headers and media type. See examples and the GET/POST shortcuts.
Build a complete REST API in Spring Boot 3 with @RestController, CRUD mappings, validation, correct status codes and centralised error handling.
Set up Spring Boot profiles for dev, test and prod: config files, activation methods, profile groups, @Profile beans and @ActiveProfiles in tests.
@Value injects properties, literals and SpEL results into Spring beans. See default values, constructor injection, SpEL and how it compares with @ConfigurationProperties.
Spring Boot maps environment variables to properties through placeholders and relaxed binding. See examples for properties, YAML, Docker and profiles.
application.yml is Spring Boot's main YAML configuration file, used to set server, datasource, logging and custom properties without recompiling.
Learn where Spring Boot reads properties from, how to bind them with @ConfigurationProperties records, and how profiles and environment variables override them.
Claims is JJWT's typed view of a verified JWT payload. See how to build tokens, read registered and custom claims, and avoid deprecated APIs.
Write a reusable JWT utility class with the current JJWT API to generate and validate tokens, then plug it into Spring Security safely.
Step-by-step JWT authentication for Spring Boot 3: sign tokens with jjwt, validate them in a stateless filter and secure endpoints with SecurityFilterChain.
Build a custom authentication filter for Spring Security 6 and later: token, provider, filter and SecurityFilterChain setup, with an API key example you can run.
The spring-security-oauth2-client dependency adds OAuth 2.0 and OpenID Connect login to Spring. Learn the starter, configuration and how to call APIs with tokens.
Enable method security with @EnableMethodSecurity and protect service methods with @PreAuthorize and SpEL, @Secured or @RolesAllowed in Spring Security 6.
Implement UserDetailsService with Spring Data JPA, build the UserDetails correctly and wire it with a SecurityFilterChain and PasswordEncoder on Spring Security 6+.