
Fix MethodArgumentNotValidException and Return Clean Errors
Handle validation failures in Spring MVC by turning MethodArgumentNotValidException and HandlerMethodValidationException into one clear error response.
Everything you need to level up your coding skills.

Handle validation failures in Spring MVC by turning MethodArgumentNotValidException and HandlerMethodValidationException into one clear error response.

Fix the 400 error for a missing request parameter in Spring MVC with optional parameters, defaults, correct parameter names and the right annotation.

Fix the 400 Bad Request caused by a request body Spring MVC cannot read, from an empty body to a wrong type, a bad enum or malformed JSON.

Fix the 415 Unsupported Media Type error by sending the right Content-Type header, matching the consumes attribute and checking the message converters.

Fix a 405 Method Not Allowed from a Spring MVC endpoint by matching the HTTP verb, the path and redirects that turn a POST into a GET.

Implement cursor (keyset) pagination in a Spring Boot API with an opaque cursor, a stable sort and a limit plus one query, using JdbcClient or Spring Data.

Add ETags to a Spring REST API: ShallowEtagHeaderFilter, strong ETags from a version, If-None-Match for 304 responses and If-Match for lost update protection.

Fix CORS errors from a browser calling a Spring Boot API by configuring allowed origins, methods and credentials, with and without Spring Security.

Implement an Idempotency-Key header in Spring Boot so a retried POST returns the first result: key storage, request hashing, concurrency and expiry.

Document a Java REST API with OpenAPI 3: springdoc-openapi in Spring Boot, annotations for summaries and responses, security schemes and exporting the spec.

JPA is a specification and Hibernate is the implementation most Java projects use. See how the two relate to Spring Data and JDBC in a running application.

Detect the Hibernate N plus 1 query problem with a statement count, then remove it with a fetch join, an entity graph or batch fetching.
We send one email when a new post is published. No spam.