Skip to main content

framework-spring-boot

Provides engineering and architecture patterns for enterprise applications with Spring Boot 3.x+, covering Spring MVC REST, constructor dependency injection, immutable DTOs (Records), Virtual Threads (Loom), validation, Spring Data JPA, and testing with Testcontainers.

ソース情報

リポジトリ
dandgabr/Coacus
ソースの最終更新活動
2026年9月20日 03:33
検出された SKILL.md の言語
英語
スター
6
フォーク
5

インストール方法

デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。

ソースファイルを確認

インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。

ファイルエクスプローラー
5 ファイル

SKILL.md を表示中

SKILL.md
ソースの指示 · 読み取り専用プレビュー
name
framework-spring-boot
description
Provides engineering and architecture patterns for enterprise applications with Spring Boot 3.x+, covering Spring MVC REST, constructor dependency injection, immutable DTOs (Records), Virtual Threads (Loom), validation, Spring Data JPA, and testing with Testcontainers.
# Spring Boot Server Engineering & Best Practices This skill establishes the software engineering standards and rules for enterprise applications and microservices built with **Spring Boot 3.x+** and modern Java (Java 17/21/25). --- ## 🧭 1. Architectural and Design Principles 1. **Clean Layer Separation**: - Keep framework annotations at the entry points (REST Controllers), configuration, and infrastructure adapters. - Avoid coupling domain classes to serialization or persistence annotations whenever possible. 2. **Idiomatic Dependency Injection**: - Strictly use constructor injection with `final` fields. Avoid direct `@Autowired` on fields (it makes testing harder and couples the class to the DI container). - Inject interfaces or specialized beans instead of direct implementation classes. 3. **Immutability and Modern DTOs**: - Use Java `record` for all Data Transfer Objects (Requests and Responses), guaranteeing immutability and structured validation with Jakarta Bean Validation (`@Valid`, `@NotNull`, `@NotBlank`, and so on). --- ## ⚡ 2. Performance, Concurrency, and Virtual Threads - **Virtual Threads (Project Loom)**: In Spring Boot 3.2+, enable `spring.threads.virtual.enabled=true` for the embedded Tomcat server and for asynchronous tasks blocked on I/O. - **Avoid Pinning**: On routes that use Virtual Threads, audit the use of `synchronized` and replace it with `ReentrantLock` in blocks that make network or database calls. - **Spring Data JPA**: Avoid N+1 queries by using `JOIN FETCH`, `@EntityGraph`, or dedicated DTO projections. --- ## 🧪 3. Testing Strategy - **Fast Unit Tests**: Test services and business rules without loading the Spring context (`MockitoExtension`, instantiating the class directly). - **Focused Layer Tests**: Use `@WebMvcTest` to validate REST endpoints, security filters, and Jackson serialization without initializing the database. - **Integration Tests with Testcontainers**: Use `@SpringBootTest` with Testcontainers for real PostgreSQL, MySQL, or Redis instances.
GitHubで見る