Spring Boot Development
Spring Boot 3+ project setup (Initializr), REST controllers, Service layer patterns, Exception handling (@ControllerAdvice), Profiles and configuration, Bean validation, Async operations
Build production Spring Boot applications using REST controllers, service layer patterns, exception handling, configuration management, and async operations.
Process
- Project Setup – Use Spring Initializr or
scripts/scaffold.py --name myapp --group-id com.example.
- REST Controllers – Create
@RestController with HTTP methods, constructor injection, DTOs.
- Service Layer – Implement
@Service with @Transactional(readOnly = true) for reads, @Transactional for writes.
- Exception Handling – Add
@RestControllerAdvice with handlers for domain exceptions, MethodArgumentNotValidException, ConstraintViolationException, and generic Exception.
- Configuration – Use
application.yml with profiles (dev, prod), @ConfigurationProperties for type-safe config.
- Bean Validation – Add
@Valid on request bodies, use @NotBlank, @NotNull, @Size, etc. on DTOs.
- Async – Use
@EnableAsync and @Async for long-running operations.
Best Practices
- Use constructor injection instead of field injection
- Use
@Transactional(readOnly = true) for read operations
- Use DTOs for API requests/responses (never expose entities)
- Implement
@ControllerAdvice for global exception handling
- Use Bean Validation for input validation
- Configure profiles for different environments
- Use
@Async for long-running operations
- Follow RESTful conventions, use
ResponseEntity for proper HTTP status codes
Anti-Patterns
| Anti-Pattern |
Fix |
Field injection with @Autowired |
Use constructor injection |
| Exposing entities directly |
Use DTOs |
Missing @Transactional on writes |
Add @Transactional |
| Synchronous blocking operations |
Use @Async |
| Hardcoded configuration |
Use @ConfigurationProperties |
| No exception handling |
Implement @ControllerAdvice |
| Missing validation |
Add Bean Validation |
Not using readOnly = true on reads |
Add to read methods |
Bundled Resources
| Resource |
Purpose |
| Installation Guide |
5-minute guide: Setup and run |
| scripts/utils.py |
Project utilities |
| scripts/validate.py |
Verify project follows skill patterns |
| REST API Patterns |
references/spring-patterns.json |
When to Use
This skill should be used when strict adherence to the defined process is required.
Prerequisites
- Basic understanding of the agent factory context.
- Access to the necessary tools and resources.
1---2agents:3- java-systems-specialist4category: parallel5description: 'Spring Boot 3+ project setup (Initializr), REST controllers, Service6 layer patterns, Exception handling (@ControllerAdvice), Profiles and configuration,7 Bean validation, Async operations89 '10knowledge:11- none12name: developing-spring-boot13related_skills:14- none15templates:16- none17tools:18- none19type: skill20version: 1.0.021references:22- none23settings:24 auto_approve: false25 retry_limit: 326 timeout_seconds: 30027 safe_to_parallelize: false28 orchestration_pattern: routing29---3031# Spring Boot Development3233Spring Boot 3+ project setup (Initializr), REST controllers, Service layer patterns, Exception handling (@ControllerAdvice), Profiles and configuration, Bean validation, Async operations3435Build production Spring Boot applications using REST controllers, service layer patterns, exception handling, configuration management, and async operations.3637## Process38391. **Project Setup** – Use Spring Initializr or `scripts/scaffold.py --name myapp --group-id com.example`.402. **REST Controllers** – Create `@RestController` with HTTP methods, constructor injection, DTOs.413. **Service Layer** – Implement `@Service` with `@Transactional(readOnly = true)` for reads, `@Transactional` for writes.424. **Exception Handling** – Add `@RestControllerAdvice` with handlers for domain exceptions, `MethodArgumentNotValidException`, `ConstraintViolationException`, and generic `Exception`.435. **Configuration** – Use `application.yml` with profiles (`dev`, `prod`), `@ConfigurationProperties` for type-safe config.446. **Bean Validation** – Add `@Valid` on request bodies, use `@NotBlank`, `@NotNull`, `@Size`, etc. on DTOs.457. **Async** – Use `@EnableAsync` and `@Async` for long-running operations.4647## Best Practices4849- Use constructor injection instead of field injection50- Use `@Transactional(readOnly = true)` for read operations51- Use DTOs for API requests/responses (never expose entities)52- Implement `@ControllerAdvice` for global exception handling53- Use Bean Validation for input validation54- Configure profiles for different environments55- Use `@Async` for long-running operations56- Follow RESTful conventions, use `ResponseEntity` for proper HTTP status codes5758## Anti-Patterns5960| Anti-Pattern | Fix |61|--------------|-----|62| Field injection with `@Autowired` | Use constructor injection |63| Exposing entities directly | Use DTOs |64| Missing `@Transactional` on writes | Add `@Transactional` |65| Synchronous blocking operations | Use `@Async` |66| Hardcoded configuration | Use `@ConfigurationProperties` |67| No exception handling | Implement `@ControllerAdvice` |68| Missing validation | Add Bean Validation |69| Not using `readOnly = true` on reads | Add to read methods |7071## Bundled Resources7273| Resource | Purpose |74|----------|---------|75| [Installation Guide](../../../../docs/setup/installation.md) | 5-minute guide: Setup and run |76| [scripts/utils.py](scripts/utils.py) | Project utilities |77| [scripts/validate.py](scripts/validate.py) | Verify project follows skill patterns |78| REST API Patterns | [references/spring-patterns.json](references/spring-patterns.json) |7980## When to Use81This skill should be used when strict adherence to the defined process is required.8283## Prerequisites84- Basic understanding of the agent factory context.85- Access to the necessary tools and resources.