java-springboot
Installation
Summary
Comprehensive best practices guide for building production-ready Spring Boot applications.
- Covers project structure, dependency injection patterns, and configuration management including externalized config, type-safe properties, and environment profiles
- Details web layer design with RESTful APIs, DTOs, validation, and global exception handling
- Addresses service layer statelessness, transaction management, and data access patterns using Spring Data JPA with custom queries and projections
- Includes logging standards with SLF4J, testing strategies across unit and integration tests with test slices and Testcontainers, and security fundamentals with Spring Security and password encoding
SKILL.md
Spring Boot Best Practices
Your goal is to help me write high-quality Spring Boot applications by following established best practices.
Project Setup & Structure
- Build Tool: Use Maven (
pom.xml) or Gradle (build.gradle) for dependency management. - Starters: Use Spring Boot starters (e.g.,
spring-boot-starter-web,spring-boot-starter-data-jpa) to simplify dependency management. - Package Structure: Organize code by feature/domain (e.g.,
com.example.app.order,com.example.app.user) rather than by layer (e.g.,com.example.app.controller,com.example.app.service).
Dependency Injection & Components
- Constructor Injection: Always use constructor-based injection for required dependencies. This makes components easier to test and dependencies explicit.
- Immutability: Declare dependency fields as
private final. - Component Stereotypes: Use
@Component,@Service,@Repository, and@Controller/@RestControllerannotations appropriately to define beans.