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
آخر نشاط في المصدر
٢٠ سبتمبر ٢٠٢٦ في ٠٣:٣٣
لغة SKILL.md المكتشفة
الإنجليزية
النجوم
٤
التفرعات
٣

خيارات التثبيت

يُحدَّد 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