springboot-patterns

Implements Spring Boot REST APIs with layered services, caching, validation, and exception handling.

2|Updated Feb 25, 2026
One-click install
npx skills add https://github.com/adamreger/ecc-antigravity --skill springboot-patterns-adamreger
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: springboot-patterns
Source: https://github.com/adamreger/ecc-antigravity/tree/main/skills/springboot-patterns
Command: npx skills add https://github.com/adamreger/ecc-antigravity --skill springboot-patterns-adamreger

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building production-grade Spring Boot backends requires consistent patterns for REST API design, data access, error handling, and cross-cutting concerns like caching and rate limiting, which are easy to get wrong or implement inconsistently. ## Core Features & Use Cases - REST API Structure: Provides controller patterns with pagination, DTO validation via Jakarta annotations, and constructor injection for thin controllers. - Data & Service Layers: Covers Spring Data JPA repositories, transactional service methods, caching with @Cacheable, and async processing with @Async. - Production Concerns: Includes global exception handling with @ControllerAdvice, Bucket4j rate limiting with secure proxy header guidance, SLF4J logging, and Micrometer observability. - Use Case: When building a new Spring Boot microservice, use this Skill to scaffold a controller-service-repository stack with validation, centralized error responses, and rate-limited endpoints. ## Quick Start Use the springboot-patterns skill to create a REST controller with a service layer, JPA repository, DTO validation, and global exception handling for a Market entity.

Frequently Asked Questions about springboot-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Spring Boot REST API with layers?▼

Structure a Spring Boot API with thin @RestController classes delegating to @Service classes, which call Spring Data JPA repositories. Use constructor injection, return ResponseEntity with DTOs, and keep business logic out of controllers.

How to handle validation errors globally in Spring Boot?▼

Use a @ControllerAdvice class with an @ExceptionHandler for MethodArgumentNotValidException to collect field errors into a single response. Spring Boot 3+ also supports RFC 7807 problem details via spring.mvc.problemdetails.enabled=true.

Does Spring Boot rate limiting work behind a reverse proxy?▼

Rate limiting by client IP requires configuring server.forward-headers-strategy and registering ForwardedHeaderFilter so request.getRemoteAddr() returns the real client IP. Never read X-Forwarded-For directly, as it is spoofable without trusted proxy configuration.

How do I add caching to a Spring Boot service?▼

Enable caching with @EnableCaching on a configuration class, then annotate service methods with @Cacheable specifying the cache name and key. Use @CacheEvict to invalidate entries when underlying data changes.

When should I use @Transactional readOnly in Spring Data JPA?▼

Apply @Transactional(readOnly = true) to query-only service methods to hint the persistence provider and database that no writes occur, enabling optimizations. Reserve write transactions for methods that create or modify entities.