301-frameworks-spring-boot-core

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spring 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.
针对注解、Bean管理、配置和依赖注入应用Spring Boot核心指南。
本Skill涵盖哪些内容?
  • @SpringBootApplication与主应用类
  • 组件注解:@RestController、@Service、@Repository
  • Bean定义、作用域、生命周期
  • 配置类与@ConfigurationProperties(搭配@Validated实现快速失败启动)
  • 组件扫描与包结构组织
  • 条件配置与配置文件(@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
    ./mvnw compile
    or
    mvn compile
    before applying any change
  • SAFETY: If compilation fails, stop immediately — compilation failure is a blocking condition
  • VERIFY: Run
    ./mvnw clean verify
    or
    mvn clean verify
    after applying improvements
  • BEFORE APPLYING: Read the reference for detailed rules, good/bad patterns, and constraints
  • EDGE CASE: If request scope is ambiguous, stop and ask a clarifying question before applying changes
  • EDGE CASE: If required inputs, files, or tooling are missing, report what is missing and ask whether to proceed with setup guidance
在应用任何Spring Boot变更前,确保项目可编译。若编译失败,立即停止操作。应用改进后,执行完整验证。
  • 强制要求:在应用任何变更前运行
    ./mvnw compile
    mvn compile
  • 安全规则:若编译失败,立即停止——编译失败属于阻塞性条件
  • 验证步骤:应用改进后运行
    ./mvnw clean verify
    mvn clean verify
  • 应用前须知:阅读参考文档获取详细规则、优劣模式及约束条件
  • 边缘场景:若请求范围模糊,停止操作并提出澄清问题后再进行变更
  • 边缘场景:若缺少所需输入、文件或工具,报告缺失内容并询问是否需要提供设置指导

When to use this skill

何时使用本Skill

  • Review Java code for Spring Boot application
  • Apply best practices for Spring Boot application in Java code
  • Improve Spring Boot configuration properties and beans
  • Review Spring Boot component scanning and profiles
  • Tune Spring Boot graceful shutdown or virtual threads
  • 评审Spring Boot应用的Java代码
  • 在Java代码中应用Spring Boot最佳实践
  • 改进Spring Boot配置属性与Bean
  • 评审Spring Boot组件扫描与配置文件
  • 优化Spring Boot优雅停机或虚拟线程

Workflow

工作流程

  1. Read reference and assess project context
Read
references/301-frameworks-spring-boot-core.md
and inspect the current project setup before proposing changes.
  1. Gather scope and decide target improvements
Identify requested outcomes, constraints, and the minimum safe set of changes to apply.
  1. Apply framework-aligned changes
Implement or refactor configuration/code following the reference patterns and project conventions.
  1. Run verification and report results
Execute appropriate build/tests and summarize what changed, what was verified, and any follow-up actions.
  1. 阅读参考文档并评估项目上下文
在提出变更前,阅读
references/301-frameworks-spring-boot-core.md
并检查当前项目配置。
  1. 确定范围并选定目标改进点
明确请求目标、约束条件,以及可应用的最小安全变更集。
  1. 应用符合框架规范的变更
遵循参考模式和项目约定实现或重构配置/代码。
  1. 执行验证并报告结果
运行相应的构建/测试,总结变更内容、验证情况及后续操作建议。

Reference

参考文档

For detailed guidance, examples, and constraints, see references/301-frameworks-spring-boot-core.md.
如需详细指导、示例及约束条件,请查看references/301-frameworks-spring-boot-core.md