Spring Boot Idioms
Learn idiomatic Spring Boot 3.x patterns grounded in auto-configuration, constructor injection, and actuator-driven observability. Covers dependency injection best practices, Spring Data JPA query methods and projections, REST controller design with DTOs, and structured logging for production readiness. Includes testing patterns for integration and controller slices.
Spring Boot Idioms teaches idiomatic patterns for Spring Boot 3.x including constructor injection, Data JPA, REST controllers, and actuator observability.
AI-generated summary based on this skill's SKILL.md
Install
irahardianto/awesome-agv/spring-boot-idioms · repository language: JavaScript
git clone https://github.com/irahardianto/awesome-agv
cp -r awesome-agv/.agents/skills/spring-boot-idioms ~/.claude/skills/spring-boot-idiomsnpx skillfed install irahardianto/awesome-agv/spring-boot-idiomsFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
What are Spring Boot best practices for dependency injection?
Spring Boot Idioms emphasizes constructor injection as the idiomatic pattern for dependency injection. Constructor-based injection makes dependencies explicit, enables immutability, and simplifies testing by allowing easy mock injection. Avoid field injection with @Autowired; instead, use constructor parameters or setter injection when appropriate. Spring Boot's auto-configuration automatically wires beans, so declare your dependencies clearly in constructors to leverage framework conventions and ensure your code remains testable and production-ready.
How do Spring Boot 3 patterns and idioms improve code quality?
Spring Boot Idioms teaches annotation-driven development and auto-configuration patterns that reduce boilerplate and enforce consistency. Spring Boot 3.x conventions handle bean registration, property binding, and lifecycle management automatically. By following idiomatic patterns—such as using @ConfigurationProperties for externalized config, @RestController with proper DTOs, and @Transactional on service methods—you write cleaner, more maintainable code that aligns with framework expectations and community standards.
What testing patterns does Spring Boot Idioms recommend?
Spring Boot Idioms covers slice-based testing with @WebMvcTest for controller layers and integration testing with TestContainers for database-backed services. Use @WebMvcTest to isolate REST controllers and verify request/response handling without loading the full context. For production-ready code, employ integration tests with real or containerized databases to validate Spring Data JPA queries and transactional behavior. These patterns ensure your code is thoroughly tested before deployment.
How does Spring Boot Idioms address observability and monitoring?
Spring Boot Idioms covers Spring Boot Actuator and Micrometer for production observability. Actuator exposes health, metrics, and environment endpoints; Micrometer standardizes metric collection across monitoring backends. The skill teaches structured logging with MDC (Mapped Diagnostic Context) for distributed tracing and includes patterns for custom metrics. These tools enable you to monitor application behavior, diagnose issues, and ensure production readiness.
What Spring Data JPA patterns does this skill teach?
Spring Boot Idioms covers Spring Data JPA query methods, custom repository implementations, and projections. Learn to write declarative queries using method naming conventions and @Query annotations, reducing boilerplate data access code. Projections allow you to fetch only required fields, improving performance. The skill also addresses transactional service patterns and proper exception handling with @ControllerAdvice, ensuring your data layer is both idiomatic and efficient.
How should I structure REST controllers and DTOs in Spring Boot?
Spring Boot Idioms teaches REST controller design using @RestController with proper separation of concerns: controllers handle HTTP concerns, services contain business logic, and DTOs (Data Transfer Objects) map between API contracts and domain models. Use @RequestBody and @ResponseBody annotations for automatic serialization. Return appropriate HTTP status codes and structure error responses consistently. This layered approach keeps your REST API clean, testable, and aligned with Spring Boot conventions.
SKILL.md
rendered from the published skill — quoted content, verbatim
Spring Boot Idioms and Patterns
Spring Boot (3.x) rewards auto-configuration, constructor injection, and actuator-driven observability. Idiomatic Spring = annotation-driven, testable, production-ready.
> Scope: Spring Boot-specific patterns. For Java: @.agents/skills/java-idioms/SKILL.md.
Dependency Injection
-
Constructor injection only — never field injection: ```java @Service public class TaskService { private final TaskRepository repository; private final TaskMapper mapper;
public TaskService(TaskRepository repository, TaskMapper mapper) { this.repository = repository; this.mapper = mapper; } } ```
-
@ConfigurationPropertiesover@Valuefor typed config.
Spring Data JPA
- Query methods for simple queries: ```java interface TaskRepository extends JpaRepository<Task, UUID> { List<Task> findByStatusOrderByCreatedAtDesc(TaskStatus status); @Query("SELECT t FROM Task t WHERE t.priority = :priority AND t.status = 'ACTIVE'") List<Task>
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
.agents/skills/spring-boot-idioms/SKILL.md