2f61ad7f1a
- 项目级 skill: .claude/skills/code-review/ (398行SKILL.md + 参考文件) - 自动触发: AI修改.py/.cbl/.cpy/.lark后自动review - CLAUDE.md: 定义触发规则、review流程、严重级别 - .code-review.yaml: tier=standard, 高风险模块配置 效果: clone即用, 每次代码变更后自动审查, 防止低质量代码入库 Co-Authored-By: Claude <noreply@anthropic.com>
2.0 KiB
2.0 KiB
Java Spring Boot Review Checklist
Extends the generic checklist with Java/Spring-specific items.
Interface Layer (Spring MVC)
@RestControllermethods have@Validon request bodies- Custom validators implement
ConstraintValidatorcorrectly @ExceptionHandleror@ControllerAdvicefor global error handling@ResponseStatusused appropriately on custom exceptions- DTOs use records or Lombok
@Data— not exposing entities directly @RequestMappingproduces/consumes specified
Business Layer (Spring Service)
@Transactionalon service methods that modify multiple tables@Transactional(rollbackFor = Exception.class)— not just RuntimeException- Transaction propagation set correctly (REQUIRED vs REQUIRES_NEW)
- No
@Transactionalon private methods (proxy limitation)
Data Layer (Spring Data JPA / MyBatis)
- JPA:
@Entityclasses have properequals()andhashCode() - JPA: No eager fetching on
@ManyToOnewithout explicit need - JPA:
@Querywith nativeQuery=false by default (prevent SQL injection) - MyBatis: All SQL uses
#{}not${}for user input - Connection pool settings reviewed (HikariCP defaults usually fine)
Error Handling
- Checked exceptions either handled or declared
try-with-resourcesfor AutoCloseable resources- No
catch (Exception e) { e.printStackTrace(); }— use logger instead
Security (Spring Security)
SecurityFilterChainconfigured correctly- CSRF protection enabled for state-changing endpoints
@PreAuthorizeor@Securedon protected methods- Password encoding uses
BCryptPasswordEncoderor better - No secrets in
application.properties— use env vars or vault
Performance
@Asyncused for non-blocking operations with proper thread pool config@Cacheablewith TTL and eviction strategy- JPA:
@BatchSizeor batch insert for bulk operations - RestTemplate/WebClient timeouts configured