301-frameworks-spring-boot-core
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSpring Boot Core Guidelines
Spring Boot 核心指南
Apply Spring Boot Core guidelines for annotations, bean management, configuration, and dependency injection.
What is covered in this Skill?
- @SpringBootApplication and main application class
- Component annotations: @RestController, @Service, @Repository
- Bean definition, scoping, lifecycle
- Configuration classes and @ConfigurationProperties (with @Validated for fail-fast startup)
- Component scanning and package organization
- Conditional configuration and profiles (@Profile, @ConditionalOn*)
- Constructor dependency injection
- @Primary and @Qualifier for disambiguation when multiple beans share a type
- Bean minimization and composition
- Graceful shutdown for in-flight work
- Virtual threads on supported stacks for concurrency-bound workloads
- Jakarta EE namespace consistency (jakarta.* preferred; avoid mixing legacy javax.annotation / javax.validation)
- Scheduled tasks and background processing
Scope: Apply recommendations based on the reference rules and good/bad code examples.
应用Spring Boot核心指南,涵盖注解、Bean管理、配置和依赖注入。
本技能包含哪些内容?
- @SpringBootApplication与主应用类
- 组件注解:@RestController、@Service、@Repository
- Bean定义、作用域、生命周期
- 配置类与@ConfigurationProperties(结合@Validated实现启动快速失败)
- 组件扫描与包结构组织
- 条件配置与Profiles(@Profile、@ConditionalOn*)
- 构造函数依赖注入
- 同类型多Bean歧义消除的@Primary与@Qualifier
- Bean最小化与组合
- 针对进行中任务的优雅停机
- 针对并发绑定工作负载,在支持的栈上使用虚拟线程
- Jakarta EE命名空间一致性(优先使用jakarta.*;避免混合使用旧版javax.annotation / javax.validation)
- 定时任务与后台处理
范围: 基于参考规则和代码示例的优劣来应用建议。
Constraints
约束条件
Before applying any Spring Boot changes, ensure the project compiles. If compilation fails, stop immediately. After applying improvements, run full verification.
- MANDATORY: Run or
./mvnw compilebefore applying any changemvn compile - SAFETY: If compilation fails, stop immediately — compilation failure is a blocking condition
- VERIFY: Run or
./mvnw clean verifyafter applying improvementsmvn clean verify - BEFORE APPLYING: Read the reference for detailed rules, good/bad patterns, and constraints
在进行任何Spring Boot修改之前,确保项目可以编译。如果编译失败,立即停止。在应用改进后,运行完整验证。
- 强制要求:在进行任何修改前运行或
./mvnw compilemvn compile - 安全要求:如果编译失败,立即停止——编译失败是阻塞性条件
- 验证要求:在应用改进后运行或
./mvnw clean verifymvn clean verify - 应用前须知:阅读参考文档以了解详细规则、优劣模式和约束条件
When to use this skill
何时使用本技能
- Review Java code for Spring Boot application
- Apply best practices for Spring Boot application in Java code
- 审查Spring Boot应用的Java代码
- 在Java代码中应用Spring Boot应用的最佳实践
Reference
参考资料
For detailed guidance, examples, and constraints, see references/301-frameworks-spring-boot-core.md.
如需详细指导、示例和约束条件,请查看references/301-frameworks-spring-boot-core.md。