应用架构与模块化单体:先学会维护一个单体
Freshness metadata
last_verified:2026-08-24version_scope:Spring Modulith current conceptssource_type:Spring official docs + architecture literaturestability:version-sensitive
核心问题不是记 DDD 名词,而是:业务边界如何划分,使代码、事务、测试和团队协作长期可维护。
flowchart LR
W[Web Adapter] --> A[Application Service]
A --> D[Domain Model/Service]
D --> R[Repository Port]
R --> I[Persistence Adapter]
A --> E[Domain Event]
E --> O[Outbox/Event Publication]
学习顺序
- package by layer 与 package by feature 的依赖差异;
- domain model、bounded context 基础与语言边界;
- application service 编排 use case,domain service 放置跨实体规则;
- repository 是领域所需持久化边界,不等于每表一个 DAO;
- ports & adapters 让业务规则不依赖 HTTP/DB;
- module verification 与 module integration test;
- transaction boundary、domain event、outbox、idempotency;
- 用 observability 看模块交互,再决定是否拆服务。