How do you handle conditional requests in REST APIs?
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.
2,881 posts about Java: questions with answers, tutorials and articles, newest first.
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+.
Step-by-step Spring Boot security with a SecurityFilterChain, role rules, database users, password encoding, HTTPS and tests in the Spring Security 6 style.
Learn three ways to define a custom CacheManager in Spring Boot: a fixed SimpleCacheManager, a dynamic AbstractCacheManager with TTLs, and a composite manager.
A step-by-step Spring Boot caching guide covering provider choice, per-cache expiry, eviction with @CachePut and @CacheEvict, and Actuator metrics.