Skip to content

feat: add five more example modules (aop, httpinterface, i18n, ratelimit, graphql) - #45

Merged
houko merged 1 commit into
mainfrom
feat/more-examples-2
Sep 13, 2026
Merged

feat: add five more example modules (aop, httpinterface, i18n, ratelimit, graphql)#45
houko merged 1 commit into
mainfrom
feat/more-examples-2

Conversation

@houko

@houko houko commented Sep 13, 2026

Copy link
Copy Markdown
Owner

概述

在上一轮示例模块(#43)之外,再补 5 个不依赖外部服务、自带可运行测试的模块:

模块 演示内容 关键点
aop AOP 切面 自定义 @Loggable + @Aspect 记录耗时与调用次数
httpinterface 声明式 HTTP 客户端 @HttpExchange + HttpServiceProxyFactoryMockRestServiceServer 测试
i18n 国际化 MessageSource + AcceptHeaderLocaleResolver,按 Accept-Language 返回文案
ratelimit 接口限流 HandlerInterceptor + 固定时间窗口;Clock 抽成 bean,测试注入可拨动时钟
graphql GraphQL 查询 @QueryMapping + .graphqls schema,提供 /graphql 端点

测试

全部通过:

aop            Tests run: 2, Failures: 0
httpinterface  Tests run: 3, Failures: 0
i18n           Tests run: 3, Failures: 0
ratelimit      Tests run: 4, Failures: 0
graphql        Tests run: 3, Failures: 0

命令:mvn -pl aop,httpinterface,i18n,ratelimit,graphql -am test

Spring Boot 4 注意点

  • aop starter 已由 spring-boot-starter-aop 改名为 spring-boot-starter-aspectj
  • 项目使用 Jackson 3,ObjectMappertools.jackson.databind 包下(注解仍在 com.fasterxml.jackson.annotation
  • 声明式 HTTP 客户端直接使用 Spring 内置 @HttpExchange,无需引入 OpenFeign

文档

  • Readme.md:模块数 21 → 26,更新模块表、技术栈、可测试模块列表
  • changeLog.md:新增条目

…mit, graphql)

- aop: @loggable annotation + @aspect to log invocation cost/count (note:
  Spring Boot 4 renamed the starter to spring-boot-starter-aspectj)
- httpinterface: @HttpExchange + HttpServiceProxyFactory declarative HTTP
  client, tested with MockRestServiceServer
- i18n: MessageSource + AcceptHeaderLocaleResolver multi-language messages
- ratelimit: HandlerInterceptor + fixed time window; Clock is a bean so the
  test injects a @primary mutable clock and never relies on sleep
- graphql: @QueryMapping + .graphqls schema exposing /graphql, tested via
  MockMvc POST

All five modules need no external service and ship with runnable tests.
Also updates Readme.md (21 -> 26 modules) and changeLog.md.
@houko
houko merged commit 5795251 into main Sep 13, 2026
4 checks passed
@houko
houko deleted the feat/more-examples-2 branch September 13, 2026 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant