Skill: spring-review
Purpose
Review Spring MVC code for alignment with the project best practices and conventions.
When to use
- During code reviews or pull requests for Spring MVC projects
- When auditing or refactoring existing MVC codebases
- Before deploying or releasing new features in a Spring MVC application
Instructions
- Layering & Architecture
- Verify clear separation between Controller, Service, and Repository layers.
- Ensure no business logic is present in controllers.
- Check for proper use of interfaces and dependency injection.
- DTO & Entity Usage
- Ensure DTOs are used for API input/output (do not expose entities directly).
- Validate mapping between DTOs and entities is handled in the service layer or with mappers.
- Error & Exception Handling
- Confirm exception handling is implemented via
@RestControllerAdviceor@ControllerAdvice. - Ensure meaningful error responses and proper HTTP status codes.
- Confirm exception handling is implemented via
- Transaction Management
- Check correct placement of
@Transactional(typically on service methods). - Avoid transactional logic in controllers.
- Check correct placement of
- Testing
- Ensure tests use appropriate Spring test slices (e.g.,
@WebMvcTest,@DataJpaTest). - Check for adequate test coverage and focus on behavior, not implementation.
- Ensure tests use appropriate Spring test slices (e.g.,
- Performance & Security
- Look for N+1 query issues and inefficient data access patterns.
- Validate input validation and security annotations (e.g.,
@Valid,@PreAuthorize).
- Documentation & Readability
- Code should be well-documented, with clear method and variable names.
- Complex logic should have comments or diagrams if needed.
Output format
Provide a checklist or table with findings for each category:
| Category | Pass/Fail | Notes/Suggestions |
|---|---|---|
| Layering & Architecture | ||
| DTO & Entity Usage | ||
| Error Handling | ||
| Transaction Management | ||
| Testing | ||
| Performance & Security | ||
| Documentation |
Summarize key issues and recommended actions at the end.