spring-framework-patterns
Apply Spring Framework best practices: dependency injection, transaction management, AOP for CIA services
来源信息
- 仓库
- Hack23/cia
- 最近来源活动
- 2026年2月1日 00:05
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 241
- Forks
- 56
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
正在显示 SKILL.md
SKILL.md
来源说明 · 只读预览- name
- spring-framework-patterns
- description
- Apply Spring Framework best practices: dependency injection, transaction management, AOP for CIA services
# 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
```java
@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
```java
@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
```java
@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
在 GitHub 查看