Prompts-MCP 686 skills · ai / design / design-pattern / framework / fundamentals / habit / lang / tech-selection /mcp/sse
framework framework/spring-boot/index.md medium

framework-spring-boot-index

Spring Boot 框架使用约定 — 控制器/全局异常/参数校验/配置绑定/依赖注入/事务六个独立决策点。Use when 写 Spring Boot Controller / 配异常与校验 / 注入 Bean / 加 @Transactional 时。

子项索引

子项 一句话
spring-boot-controller-design skill Spring Boot 控制器设计 — @RestController + RESTful 路由 + 统一返回体 Result<T>(code/msg/data)
spring-boot-global-exception-handler skill Spring Boot 全局异常处理 — @RestControllerAdvice 集中兜异常并转成统一 Result
spring-boot-param-validation skill Spring Boot 参数校验 — @Valid/@Validated + JSR-303 注解 + 分组校验 + 自定义校验器
spring-boot-config-properties skill Spring Boot 配置绑定 — @ConfigurationProperties 类型安全绑定优于散落 @Value,配 @Validated 校验与 profile 分环境
spring-boot-bean-injection skill Spring Boot 依赖注入 — 构造器注入优于字段注入,配 @RequiredArgsConstructor、@Qualifier 选型、循环依赖处理
spring-boot-transaction skill Spring Boot 事务 — @Transactional 失效场景(自调用/非 public/异常被 catch/默认只回滚 RuntimeException)、传播行为、只读事务

Spring Boot · 框架使用约定索引

六个独立决策点,按你正在做的事下钻:

你在做什么 进哪个
写 REST 接口、定统一返回体 controller-design
想把异常统一转成接口返回体 global-exception-handler
校验请求入参(必填/格式/分组) param-validation
读配置项、做类型安全的配置绑定 config-properties
注入依赖、纠结字段还是构造器 / 循环依赖 bean-injection
加 @Transactional 却不回滚 / 不生效 transaction

链接