|
| 1 | +# Role |
| 2 | + |
| 3 | + |
| 4 | +You're a senior software craft developper respecting SOLID, KISS, DRY. |
| 5 | +Make sure your code is easy to read and has no cognitive complexity. |
| 6 | + |
| 7 | +# Java Spring Boot Skill |
| 8 | + |
| 9 | +Build production-ready Spring Boot applications with modern best practices. |
| 10 | + |
| 11 | +## ⚡ RÈGLES NON-NÉGOCIABLES |
| 12 | + |
| 13 | +1. ❌ NEVER do N+1 query |
| 14 | +2. ✅ ALWAYS respect SOLID principles |
| 15 | + |
| 16 | +## Overview |
| 17 | + |
| 18 | +This skill covers Spring Boot development including REST APIs, security configuration, data access, actuator monitoring, and cloud integration. Follows Spring Boot 3.x patterns with emphasis on production readiness. |
| 19 | + |
| 20 | +## When to Use This Skill |
| 21 | + |
| 22 | +Use when you need to: |
| 23 | +- Create REST APIs with Spring MVC/WebFlux |
| 24 | +- Configure Spring Security (OAuth2, JWT) |
| 25 | +- Set up database access with Spring Data |
| 26 | +- Enable monitoring with Actuator |
| 27 | +- Integrate with Spring Cloud |
| 28 | + |
| 29 | +## Topics Covered |
| 30 | + |
| 31 | +### Spring Boot Core |
| 32 | +- Auto-configuration and starters |
| 33 | +- Application properties and profiles |
| 34 | +- Bean lifecycle and configuration |
| 35 | +- DevTools and hot reload |
| 36 | + |
| 37 | +### REST API Development |
| 38 | +- @RestController and @RequestMapping |
| 39 | +- Request/response handling |
| 40 | +- Validation with Bean Validation |
| 41 | +- Exception handling with @ControllerAdvice |
| 42 | + |
| 43 | +### Spring Security |
| 44 | +- SecurityFilterChain configuration |
| 45 | +- OAuth2 and JWT authentication |
| 46 | +- Method security (@PreAuthorize) |
| 47 | +- CORS and CSRF configuration |
| 48 | + |
| 49 | +### Spring Data JPA |
| 50 | +- Repository pattern |
| 51 | +- Query methods and @Query |
| 52 | +- Pagination and sorting |
| 53 | +- Auditing and transactions |
| 54 | + |
| 55 | +### Actuator & Monitoring |
| 56 | +- Health checks and probes |
| 57 | +- Metrics with Micrometer |
| 58 | +- Custom endpoints |
| 59 | +- Prometheus integration |
| 60 | + |
| 61 | +## Quick Reference |
| 62 | + |
| 63 | +```java |
| 64 | +// REST Controller |
| 65 | +@RestController |
| 66 | +@RequiredArgsConstructor |
| 67 | +@Slf4j |
| 68 | +@Validated |
| 69 | +@Tag(name = "02. Survey-units", description = "Endpoints for survey-units") |
| 70 | +public class SurveyUnitClosingController { |
| 71 | + |
| 72 | + private final DomainFeaturePort domainFeaturePort; |
| 73 | + |
| 74 | + // Example Post |
| 75 | + @PostMapping(API_PATH) |
| 76 | + public ResponseEntity<Void> addClosingCauseToMultipleSurveyUnits( |
| 77 | + @RequestBody @Valid ObjectRequest request) { |
| 78 | + |
| 79 | + domainFeaturePort.domainMethod(request.getObject1(), request.getObject2()); |
| 80 | + return ResponseEntity.ok().build(); |
| 81 | + } |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +## Common Patterns |
| 86 | + |
| 87 | +### Validation Patterns |
| 88 | +```java |
| 89 | +public record CreateUserRequest( |
| 90 | + @NotBlank @Size(max = 100) String name, |
| 91 | + @Email @NotBlank String email, |
| 92 | + @NotNull @Min(18) Integer age |
| 93 | +) {} |
| 94 | +``` |
| 95 | + |
| 96 | +## Troubleshooting |
| 97 | + |
| 98 | +### Common Issues |
| 99 | + |
| 100 | +| Problem | Cause | Solution | |
| 101 | +|---------|-------|----------| |
| 102 | +| Bean not found | Missing @Component | Add annotation or @Bean | |
| 103 | +| Circular dependency | Constructor injection | Use @Lazy or refactor | |
| 104 | +| Slow startup | Heavy auto-config | Exclude unused starters | |
| 105 | + |
| 106 | + |
| 107 | +### Debug Checklist |
| 108 | +``` |
| 109 | +□ Check /actuator/conditions |
| 110 | +□ Verify active profiles |
| 111 | +□ Review security filter chain |
| 112 | +□ Check bean definitions |
| 113 | +□ Test health endpoints |
| 114 | +``` |
0 commit comments