Java & Spring Boot Tutorials
Hands-on Java and Spring Boot: build, document and secure REST APIs, call other services, and write modern Java.
Replace OAuth2RestTemplate with RestClient: A Modern Spring Boot API Client
In the previous post, we built a program that walks an Order API (buyers, suppliers, customer numbers, articles) and places a test order. It works, but it’s built on OAuth2RestTemplate,...
Build a RESTful Web Service with Spring Boot, Gradle, and OpenAPI
By the end of this guide you’ll have a working Spring Boot RESTful API, built with Gradle and documented with OpenAPI, and a live Swagger UI page you can show...
Generate a Spring Boot Server from an OpenAPI Spec with Swagger Codegen
You’ve designed your API. Now comes the boring part: writing controllers, models and request mappings that only repeat what the spec already says. Swagger Codegen writes that code for you....
Design-First APIs with OpenAPI 3: A Step-by-Step Tutorial
Most API problems aren’t coding problems. They’re design problems found too late: a missing field, an inconsistent name, an error nobody documented. Design-first fixes that by agreeing on the contract...
Break Out of Nested Loops in Java: Automating a Real REST API Client
Testing an order API by hand means clicking through buyers, suppliers, customer numbers and articles until you find a combination that works. This program does it in seconds: it walks...
Log Every Login Attempt with Spring Boot Actuator Auditing
When a login fails at 3 a.m., you want to know who tried, how often, and whether it worked. Spring Boot Actuator already publishes these security events; you only have...
Java OCP Practice Questions: Building Blocks, with Answers Explained
The OCP Java exam doesn’t test whether you can write code. It tests whether you can read code like a compiler: which line fails, what exactly gets printed, which object...
Java Bit Flags with Enums: Combine, Check and Decode Errors with Bitwise Operators and EnumSet
An order API has to report several problems at once: a wrong quantity, a price difference and an article that no longer exists. Sending a list of strings works, but...
Java Generics Explained: Wildcards, PECS and Type Erasure with Examples
Before Java 5, every collection held Object, and every value you took out needed a cast, which could fail at runtime. Generics moved that check to the compiler. Here’s how...
Functional Programming in Java: Lambdas, Streams, Records and Immutability
You already use functional programming in Java every time you write a lambda or a stream. Used well, it turns a 20-line loop over orders into five readable lines. Used...
Java App Slow Under Load? A Step-by-Step Performance Playbook
Your Java application works fine in testing, then falls over in production: requests pile up, the database runs out of connections, the server stops responding. The fix is rarely “add...
Load-Test Your API's Rate Limiting with Concurrent Java Clients
Your API has rate limiting. But does it actually work when several clients hammer different endpoints at the same time, on Black Friday? You don’t want to find out in...
REST API Tutorial: Resources, HTTP Methods, Status Codes and a Spring Boot Example
A restaurant app needs a supplier’s food prices; the supplier’s system needs the restaurant’s orders. Two companies, two technologies, no shared code, and REST is how they talk. This tutorial...
Rate Limiting in Spring Boot with Bucket4j: Token Bucket Algorithm per Client
A partner company starts integrating with your API. On day one, their developer writes a loop to load test data, and suddenly your API answers slowly for every other client....
How a REST Client Should Handle 503 Service Unavailable: Retries with Backoff in Spring
Your nightly job sends 50,000 articles to a partner’s API, in batches of 1,000. At batch 23, the API answers 503 Service Unavailable. What should your client do? Give up,...
Fix 'Received fatal alert: handshake_failure' in Java: SSL/TLS Troubleshooting
Your Java client calls an HTTPS API and fails before sending a single request:
Secure a Spring Boot REST API with OAuth2 and OpenAPI (Swagger UI)
Your REST API is documented with OpenAPI, and anyone who finds the URL can call it. This tutorial secures it with OAuth2: clients get a short-lived access token and send...
Document a Spring Boot REST API with OpenAPI 3 and Swagger UI (springdoc)
Developers outside your team can’t read your code. They read your API documentation, and if it’s missing, out of date or wrong, they guess, open tickets, or pick another provider....