SKILL

springboot-patterns

Spring Boot architecture patterns, REST API design, layered services, data access, caching, asynchronous processing, and logging. For Java Spring Boot backend work.

Machine translation
Read the original Chinese text

Spring Boot架构模式、REST API设计、分层服务、数据访问、缓存、异步处理和日志记录。用于Java Spring Boot后端工作。

Target: Software development & testing. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • Spring Boot 开发模式
  • 何时激活
  • REST API 结构
  • 仓库模式 (Spring Data JPA)
  • 带事务的服务层
  • DTO 和验证
  • 异常处理
  • 缓存

用于可扩展、生产级服务的 Spring Boot 架构和 API 模式。 使用 Spring MVC 或 WebFlux 构建 REST API 构建控制器 → 服务 → 仓库层结构 配置 Spring Data JPA、缓存或异步处理 添加验证、异常处理或分页 为开发/预发布/生产环境设置配置文件 使用 Spring Events 或 Kafka 实现事件驱动模式 需要在配置类上使用 @EnableCaching。 需要在配置类上使用 @EnableAsync。 安全须知:默认情况下 X-Forwarded-For 头是不可信的,因为客户端可以伪造它。 仅在以下情况下使用转发头: 1. 您的应用程序位于可信的反向代理(nginx、AWS ALB 等)之后 2. 您已将 ForwardedHeaderFilter 注册为 bean 3. 您已在应用属性中配置了 server.forward-headers-strategy=NATIVE 或 FRAMEWORK 4. 您的代理配置为覆盖(而非追加)X-Forwarded-For 头 当 ForwardedHeaderFilter 被正确配置时,request.getRemoteAddr() 将自动从转发的头中返回正确的客户端 IP。 没有此配置时,请直接使用 request.getRemoteAddr()——它返回的是直接连接的 IP,这是唯一可信的值。 使用 Spring 的 @Scheduled 或与队列(如 Kafka、SQS、RabbitMQ)集成。保持处理程序是幂等的和可观察的。 通过 Logback 编码器进行结构化日志记录 (JSON) 指标:Micrometer + Prometheus/OTel 追踪:带有 OpenTelemetry 或 Brave 后端的 Micrometer Tracing 优先使用构造函数注入,避免字段注入 启用 spring.mvc.problemdetails.enabled=true 以获得 RFC 7807 错误 (Spring Boot 3+) 根据工作负载配置 HikariCP 连接池大小,设置超时 对查询使用 @Transactional(readOnly = true) 在适当的地方通过 @NonNull 和 Optional 强制执行空值安全 记住:保持控制器精简、服务专注、仓库简单,并集中处理错误。为可维护性和可测试性进行优化。

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/springboot-patterns/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Requirements

  • Only the author’s Skill metadata is included. Read the full instructions to check dependencies, licensing and conditions of use.

A small first task

先阅读原作者说明,再决定是否在自己的 AI 工具中使用。

Instructions for your AI tool

Author documentation is not live verification by this site. Without evidence, we do not mark a resource as compatible, safe or free.

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.626Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.