Spring Boot patterns, best practices, and code generation for REST APIs, JWT authentication, JPA, pagination, and modern Spring Boot development (Java 21+, Spring Boot 4.x)
Install
npx skillscat add halilugur/spring-boot-ultimate Install via the SkillsCat registry.
SKILL.md
Spring Boot Ultimate
A comprehensive skill for Spring Boot development providing code snippets, patterns, and best practices for building modern Spring Boot applications.
Tech Stack
- Java: 21+ with records and pattern matching
- Spring Boot: 4.x
- Security: JWT-based stateless authentication with Spring Security 6
- Database: JPA/Hibernate with UUID primary keys
- Build: Maven
Core Patterns Reference
This skill includes reference implementations in the assets/ directory demonstrating:
1. Base Entity Pattern (assets/entities/BaseEntity.java)
All entities should extend BaseEntity which provides:
- TIME-based UUID primary key (
@UuidGenerator(style = TIME)) - Automatic timestamps (
createdAt,updatedAt) - Soft delete flag (
isEnable)
@Setter
@Getter
@MappedSuperclass
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseEntity implements Serializable {
@Id
@UuidGenerator(style = UuidGenerator.Style.TIME)
private String id;
@CreationTimestamp
private LocalDateTime createdAt;
@UpdateTimestamp
private LocalDateTime updatedAt;
private boolean isEnable = true;
}2. Response Wrapper Pattern (assets/responses/response/Response.java, assets/responses/response/PageResponse.java)
Response<T>: Standard API response wrapper withsuccess,data,errorPageResponse<T>: Extends Response with pagination metadata- Uses
@SuperBuilderfor inheritance with builder pattern
3. Controller Pattern (assets/controllers/UserController.java)
@RequiredArgsConstructorfor constructor injectionResponseEntityfor proper HTTP responses@PreAuthorizefor method-level security@PageableDefaultfor pagination defaults
4. Service Pattern (assets/services/AuthService.java)
@Transactional(readOnly = true)at class level@Transactionalfor write methods- Clean separation between authentication and business logic
5. Mapper Pattern (assets/mappers/UserMapper.java)
- Static utility class with private constructor
- Separate methods for different request types
- Entity <-> DTO conversion methods
6. Security Pattern (assets/security/)
JwtTokenProvider: JWT generation and validationJwtAuthenticationFilter: Stateless JWT filterSecurityConfig: Spring Security 6 configuration with method security
7. Configuration Pattern (assets/config/)
- Type-safe
@ConfigurationPropertiesclasses - Separate configs for CORS, JWT, etc.
When to Use This Skill
Invoke this skill when working on:
- Creating new REST endpoints
- Implementing JWT authentication
- Setting up JPA entities and repositories
- Configuring Spring Security
- Implementing pagination
- Writing service layer logic
- Creating DTOs and mappers
Code Generation
When asked to generate code, provide:
- Code snippets for the specific pattern/component
- Brief explanation of the pattern
- Assets to full implementations in
assets/directory
Code Review
When reviewing Spring Boot code, check for:
- Proper use of
BaseEntityfor all entities - Response wrapping with
Response<T>orPageResponse<T> - Constructor injection via
@RequiredArgsConstructor @Transactionalusage (readOnly for queries)- Method-level security with
@PreAuthorize - Proper JWT validation in security filter
Learning Resources
For detailed examples, see:
- references/rest-api.md - REST API patterns
- references/authentication.md - JWT authentication
- references/pagination.md - Pagination patterns
For system architecture overview:
- references/architecture.md - Complete architecture documentation with diagrams and data flows
Pattern Documentation
For deep dives into specific patterns: