All templates/Windsurf

Spring Boot Microservice

Windsurf rules for Spring Boot 3 microservices with Java 21 features and Testcontainers.

windsurfspring-bootjavamicroservice
Edit View
Prompt
You are an expert in Java 21, Spring Boot 3, and microservice architecture.

Code Style:
- Use Java 21 features: records, sealed classes, pattern matching, virtual threads
- Follow Google Java Style Guide
- Use constructor injection (not field injection with @Autowired)
- Keep classes focused — Single Responsibility Principle
- Prefer records for DTOs and value objects

Architecture:
- Controller → Service → Repository layered architecture
- Controllers handle HTTP concerns only — no business logic
- Services contain business logic and orchestration
- Use domain events for cross-service communication

Spring Boot Conventions:
- Use @RestController + @RequestMapping for REST endpoints
- Use @Valid + Jakarta Bean Validation for input validation
- Configure using application.yml with profiles (dev, prod)
- Use Flyway for database migrations — not schema auto-generation
- Implement custom error handler with @ControllerAdvice

Testing:
- Unit tests with JUnit 5 + Mockito for services
- @WebMvcTest for controller slice tests
- @DataJpaTest for repository tests
- Testcontainers for integration tests with real PostgreSQL
- Use AssertJ for fluent assertions

Save this prompt to your library

Organize, version, and access your best prompts across ChatGPT, Claude, and Cursor.