How do you implement JWT authentication in Spring Boot?
Use Spring Security's OAuth2 resource server to issue and validate signed JWTs, with a stateless filter chain and short-lived tokens.
2,886 posts about Java: questions with answers, tutorials and articles, newest first.
Use Spring Security's OAuth2 resource server to issue and validate signed JWTs, with a stateless filter chain and short-lived tokens.
@PreAuthorize in Spring Security evaluates a SpEL rule before a method runs. Learn setup, expressions, custom rule beans and testing with examples.
Set up HTTP Basic authentication in Spring Security 6 with SecurityFilterChain, BCrypt users, stateless sessions, a custom 401 and MockMvc tests.
Spring Security authenticates users, authorizes requests and blocks common web attacks through a filter chain. Learn the modern SecurityFilterChain setup for Spring Boot 3 and later.
Secure a Spring Boot REST API with a stateless SecurityFilterChain, role checks, password encoding and JWT validation using the modern Spring Security 6 style.
@EnableScheduling activates @Scheduled methods in Spring. See cron, fixedRate and fixedDelay, the single-thread default and multi-instance pitfalls.
Spring cron expressions have six fields starting with seconds. Learn the syntax, @Scheduled usage, time zones, property placeholders and clustering caveats.
TaskScheduler schedules Runnable tasks at a time, fixed rate, fixed delay or cron trigger. Learn Spring Boot configuration, examples and pitfalls.
Spring @Async has no built-in timeout. Learn four reliable ways to limit waiting and stop long-running async tasks, and the proxy pitfall to avoid.
Enable @EnableAsync, define a bounded ThreadPoolTaskExecutor and reference it from @Async. Includes Spring Boot properties, exceptions and virtual threads.
@Async runs a Spring method on a separate thread so the caller does not wait. Learn setup, executors, CompletableFuture results and common pitfalls.
Run work in the background in Spring Boot using @Async, tuned executors, virtual threads, and CompletableFuture, with the proxy pitfalls explained.
CacheManager is Spring's registry of named caches. It lets @Cacheable work with Caffeine, Redis or any provider, with TTL and size set in one place.
Configure Spring Boot caching with @Cacheable, Caffeine or Redis, per-cache TTL, cache managers and fixes for common mistakes.
Configure Redis as the Spring Boot cache: dependencies, spring.data.redis properties, annotations, JSON serialization, per-cache TTL and error handling.
Use the AWS SDK for Java v2 Enhanced Client in Spring Boot to create, read, update and delete DynamoDB items, and learn why DynamoDBMapper and SDK v1 are legacy.
Spring's @Cacheable stores a method result so repeated calls skip the work. See setup, key, condition and unless attributes, and common pitfalls.
DynamoDBMapper is the AWS SDK v1 object mapper for DynamoDB, now out of support. See what it did and how to replace it with the Enhanced Client in Spring Boot.
Use Spring Boot's cache starter, spring.cache properties and Actuator to cache REST API data with Caffeine or Redis, and add ETag support for clients.
Connect Spring Boot to DynamoDB with the AWS SDK v2 Enhanced Client: configure beans, map a model, write a repository and test with DynamoDB Local.