spring-framework-patterns
Apply Spring Framework best practices: dependency injection, transaction management, AOP for CIA services
Installation
Suivez les instructions du dépôt pour votre agent. Consultez les fichiers et dépendances avant l’installation.
Voir la source ↗GuidesInstructions
Spring Framework Patterns Skill
Purpose
Apply Spring Framework best practices for dependency injection, transactions, and aspect-oriented programming.
When to Use
- ✅ Creating Spring services and components
- ✅ Managing transactions
- ✅ Implementing cross-cutting concerns
- ✅ Configuring application context
Dependency Injection Patterns
@Service
public class PoliticianService {
private final PoliticianRepository repository;
private final AuditLogger auditLogger;
// Constructor injection (preferred)
public PoliticianService(
PoliticianRepository repository,
AuditLogger auditLogger) {
this.repository = repository;
this.auditLogger = auditLogger;
}
}
Transaction Management
@Service
@Transactional(readOnly = true)
public class VotingService {
@Transactional
public void recordVote(Vote vote) {
voteRepository.save(vote);
statisticsService.updateStats(vote);
auditLogger.log("VOTE_RECORDED", vote.getId());
}
}
Aspect-Oriented Programming
@Aspect
@Component
public class PerformanceMonitoringAspect {
@Around("@annotation(Monitored)")
public Object monitor(ProceedingJoinPoint joinPoint) throws Throwable {
long start = System.currentTimeMillis();
try {
return joinPoint.proceed();
} finally {
long duration = System.currentTimeMillis() - start;
log.info("Method {} took {}ms",
joinPoint.getSignature().getName(), duration);
}
}
}
References
- Spring Framework: https://docs.spring.io/spring-framework/reference/
- ARCHITECTURE.md
Exemples
Consultez les exemples du dépôt source.
Voir la source ↗Historique source
- Date d’indexation
- 2026-03-11
- Mise à jour de l’index
- 2026-03-11
- Branch
- main
Les dates concernent ce répertoire. Consultez le dépôt pour l’historique du code.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!