#spring-boot
15 snippets tagged with #spring-boot
Spring Boot REST Controller with CRUD
Create a complete REST API with Spring Boot: GET, POST, PUT, DELETE with validation and error handling.
Best for: Building RESTful APIs with Spring Boot
Spring Boot Global Exception Handler
Centralized error handling with @ControllerAdvice for validation errors, 404s, and custom exceptions.
Best for: Consistent error responses across all endpoints
Spring Security — JWT Authentication
Implement JWT authentication with Spring Security: token generation, validation, and filter chain.
Best for: Securing REST APIs with JWT tokens
Spring Boot — Custom Validator Annotation
Create custom validation annotations with ConstraintValidator for domain-specific field validation.
Best for: Domain-specific input validation
Spring Boot Caching with Redis
Add caching to Spring Boot services with @Cacheable, @CacheEvict, TTL configuration, and Redis.
Best for: Reducing database load with application-level caching
Spring Boot — Scheduled Tasks and Cron
Schedule background tasks with @Scheduled: fixed rate, fixed delay, cron expressions, and async tasks.
Best for: Background job scheduling in Spring Boot
Spring WebFlux — Reactive REST API
Build reactive REST APIs with Spring WebFlux using Mono, Flux, and non-blocking operations.
Best for: High-throughput non-blocking APIs
Spring Boot — Profiles and Configuration
Manage environment-specific config with Spring profiles: application-{env}.yml, @Profile, and @Value.
Best for: Environment-specific application configuration
Spring Boot AOP — Aspects and Advice
Use Spring AOP for cross-cutting concerns: logging, timing, auditing, and transaction-like behavior.
Best for: Automatic method logging across services
Spring Boot — Application Events
Use Spring's event system for decoupled communication: custom events, async listeners, and ordering.
Best for: Decoupled event-driven service communication
Spring Security — Role-Based Access Control
Configure RBAC with Spring Security: roles, method security, endpoint permissions, and custom filters.
Best for: Fine-grained API endpoint authorization
Spring Boot — RestClient HTTP Calls
Make HTTP requests with Spring RestClient (6.1+): GET, POST, error handling, interceptors, and timeouts.
Best for: REST API consumption in Spring Boot services
Spring Boot Integration Testing
Write Spring Boot integration tests with MockMvc, test slices, TestContainers, and mock beans.
Best for: REST API endpoint verification
Spring Boot REST API in Kotlin
Build a REST API with Spring Boot and Kotlin: controllers, services, error handling, and validation.
Best for: RESTful API development with Kotlin
Spring WebFlux with Kotlin Coroutines
Build reactive Spring APIs using Kotlin coroutines: suspend functions, Flow, and coRouter DSL.
Best for: Non-blocking REST APIs with Kotlin coroutines