ddd4j-project-creator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDDD4j Project Creator
DDD4j 项目创建器
When to use this skill
何时使用此技能
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project, initializing ddd4j project, or setting up ddd4j-boot project.
ALWAYS use this skill when the user mentions:
- Creating a ddd4j project (explicitly mentions "ddd4j")
- Initializing ddd4j-boot project
- Setting up ddd4j project structure
- Creating ddd4j project scaffolding
- 创建 ddd4j 项目 (explicitly mentions "ddd4j")
- 初始化 ddd4j 项目 (initialize ddd4j project)
- ddd4j-boot 项目创建 (create ddd4j-boot project)
Trigger phrases include:
- "创建 ddd4j 项目" (create ddd4j project) - must include "ddd4j"
- "初始化 ddd4j 项目" (initialize ddd4j project) - must include "ddd4j"
- "创建 ddd4j-boot 项目" (create ddd4j-boot project) - must include "ddd4j"
- "使用 ddd4j 创建项目" (create project using ddd4j)
- "ddd4j 项目脚手架" (ddd4j project scaffolding)
DO NOT trigger this skill for:
- Generic DDD projects without mentioning ddd4j
- JPA/Hibernate projects
- Other ORM frameworks
- Generic project initialization without ddd4j context
- "创建 DDD 项目" without "ddd4j" (too generic)
- "初始化项目" without "ddd4j" (too generic)
重要提示:仅当用户明确提及创建ddd4j项目、初始化ddd4j项目或搭建ddd4j-boot项目时,才可触发此技能。
当用户提及以下内容时,务必使用此技能:
- 创建ddd4j项目(明确提及“ddd4j”)
- 初始化ddd4j-boot项目
- 搭建ddd4j项目结构
- 创建ddd4j项目脚手架
- 创建 ddd4j 项目(明确提及“ddd4j”)
- 初始化 ddd4j 项目
- ddd4j-boot 项目创建
触发短语包括:
- "创建 ddd4j 项目" - 必须包含“ddd4j”
- "初始化 ddd4j 项目" - 必须包含“ddd4j”
- "创建 ddd4j-boot 项目" - 必须包含“ddd4j”
- "使用 ddd4j 创建项目"
- "ddd4j 项目脚手架"
请勿触发此技能的场景:
- 未提及ddd4j的通用DDD项目
- JPA/Hibernate项目
- 其他ORM框架相关项目
- 无ddd4j上下文的通用项目初始化
- 未包含“ddd4j”的“创建 DDD 项目”(过于通用)
- 未包含“ddd4j”的“初始化项目”(过于通用)
About DDD4j Boot
关于DDD4j Boot
DDD4j Boot is a Java microservice development scaffold based on Domain-Driven Design (DDD) principles. It is built with Spring Boot 3.5.x and uses lightweight ddd-4-java and cqrs-4-java libraries to implement Domain-Driven Design, Command Query Responsibility Segregation (CQRS), and Event Sourcing.
DDD4j Boot 是一款基于**领域驱动设计(DDD)**原则的Java微服务开发脚手架。它基于Spring Boot 3.5.x构建,采用轻量级的ddd-4-java和cqrs-4-java库来实现领域驱动设计、命令查询职责分离(CQRS)以及事件溯源。
Core Design Principles
核心设计原则
- Domain-Driven Design (DDD): Strategic design through bounded contexts, tactical design with entities, value objects, aggregates, domain services, repositories, and domain events
- Command Query Responsibility Segregation (CQRS): Separation of read and write models, independent optimization
- Event Sourcing: State changes recorded as event sequences, supporting complete history and state reconstruction
- Diamond Architecture (COLA): Adapter → Application → Domain ← Infrastructure four-layer architecture
- 领域驱动设计(DDD):通过限界上下文进行战略设计,通过实体、值对象、聚合、领域服务、仓库和领域事件进行战术设计
- 命令查询职责分离(CQRS):读写模型分离,可独立优化
- 事件溯源:将状态变更记录为事件序列,支持完整历史追溯和状态重建
- 菱形架构(COLA):适配器→应用→领域←基础设施四层架构
Key Features
关键特性
- Complete DDD layered architecture supporting COLA V5 pattern
- Lightweight DDD implementation based on ddd-4-java and cqrs-4-java
- Technology stack integration: Spring Boot 3.5.x, MyBatis Plus, Jackson, Guava, Swagger, SaToken
- Dual stack support: WebMVC (traditional Servlet) and WebFlux (reactive)
- Domain model base capabilities: BaseEntity, BaseRepository, BaseService
- Domain event support with built-in event publishing mechanism
- Anti-Corruption Layer (ACL) for external service integration
- Unified exception handling mechanism
- 支持COLA V5模式的完整DDD分层架构
- 基于ddd-4-java和cqrs-4-java的轻量级DDD实现
- 技术栈集成:Spring Boot 3.5.x、MyBatis Plus、Jackson、Guava、Swagger、SaToken
- 双栈支持:WebMVC(传统Servlet)和WebFlux(响应式)
- 领域模型基础能力:BaseEntity、BaseRepository、BaseService
- 内置事件发布机制的领域事件支持
- 用于外部服务集成的防腐层(ACL)
- 统一异常处理机制
Project Types Supported
支持的项目类型
1. Single-Module Monolith (单体单模块)
1. 单体单模块
适用场景: 中小型应用,单个业务领域,团队规模 5-15 人
特点:
- 单一 Maven 模块
- 所有层(interfaces, application, domain, infrastructure)在同一模块内
- 适合快速开发和部署
适用场景: 中小型应用,单一业务领域,团队规模5-15人
特点:
- 单一Maven模块
- 所有层级(interfaces、application、domain、infrastructure)位于同一模块内
- 适合快速开发与部署
2. Multi-Module Monolith (单体多模块)
2. 单体多模块
适用场景: 中大型应用,多个业务域,团队规模 15-50 人
特点:
- 多个 Maven 模块,按业务域划分
- 每个业务域包含完整的 DDD 四层架构
- 共享 common 模块
- 统一 BOM 和依赖管理
适用场景: 中大型应用,多个业务域,团队规模15-50人
特点:
- 多个Maven模块,按业务域划分
- 每个业务域包含完整的DDD四层架构
- 共享common模块
- 统一的BOM和依赖管理
3. Microservices (单体微服务)
3. 微服务
适用场景: 大型电商平台,多个业务域,团队规模 50+ 人
特点:
- 每个服务独立部署
- 服务间通过 RPC 和消息队列通信
- 每个服务内部按 DDD 四层架构组织
- 独立的数据库和配置
适用场景: 大型电商平台,多个业务域,团队规模50+人
特点:
- 每个服务独立部署
- 服务间通过RPC和消息队列通信
- 每个服务内部按DDD四层架构组织
- 独立的数据库和配置
How to use this skill
如何使用此技能
CRITICAL: This skill should ONLY be triggered when the user explicitly mentions creating a ddd4j project. Do NOT trigger for generic DDD project creation requests without ddd4j context.
重要提示:仅当用户明确提及创建ddd4j项目时,才可触发此技能。若用户请求的是无ddd4j上下文的通用DDD项目创建,请勿触发。
For New DDD4j Project Creation
新建DDD4j项目
-
Identify the project type from user requirements:
- Single-module monolith →
single-module - Multi-module monolith →
multi-module - Microservices →
microservices
- Single-module monolith →
-
Load the appropriate example from thedirectory:
examples/- - Single-module monolith structure
examples/single-module.md - - Multi-module monolith structure
examples/multi-module.md - - Microservices structure
examples/microservices.md - - DDD, Hexagonal, Clean, COLA V5 patterns
examples/architecture-patterns.md
-
Collect project information:
- : Maven group ID (e.g.,
groupIdorcom.github.hiwepy)io.ddd4j.base - : Maven artifact ID (e.g.,
artifactIdorddd4j-douyin)my-ddd4j-service - : Project version (e.g.,
version)1.0.0-SNAPSHOT - : Parent POM version (e.g.,
parentVersionor reference to2023.0.x.20251205-SNAPSHOT)ddd4j-boot-parent - : Base package name (e.g.,
packageBaseorio.ddd4j.douyin)com.example.service - : List of business modules (for multi-module/microservices)
modules - : Architecture pattern (DDD Classic, Hexagonal, Clean, COLA V5)
architecture - : DDD4j Boot version (if using ddd4j-boot-bom)
ddd4jBootVersion
-
Generate project structure:
- Create directory structure based on selected type
- Generate files (parent and modules)
pom.xml - Create files for each module
package-info.java - Generate ,
.gitignore,LICENSE,mvnwmvnw.cmd - Create basic directory structure with and
src/main/javasrc/test/java
-
Save to project directory:
- Default location: Save directly to the command execution directory (same level as the command)
- Directory creation: Automatically create the project directory structure if it doesn't exist
- File naming: Use descriptive names based on project type and module names
-
根据用户需求确定项目类型:
- 单体单模块 →
single-module - 单体多模块 →
multi-module - 微服务 →
microservices
- 单体单模块 →
-
从目录加载对应示例:
examples/- - 单体单模块结构
examples/single-module.md - - 单体多模块结构
examples/multi-module.md - - 微服务结构
examples/microservices.md - - DDD、六边形、整洁、COLA V5模式
examples/architecture-patterns.md
-
收集项目信息:
- : Maven组ID(例如:
groupId或com.github.hiwepy)io.ddd4j.base - : Maven工件ID(例如:
artifactId或ddd4j-douyin)my-ddd4j-service - : 项目版本(例如:
version)1.0.0-SNAPSHOT - : 父POM版本(例如:
parentVersion或引用2023.0.x.20251205-SNAPSHOT)ddd4j-boot-parent - : 基础包名(例如:
packageBase或io.ddd4j.douyin)com.example.service - : 业务模块列表(适用于多模块/微服务)
modules - : 架构模式(DDD经典、六边形、整洁、COLA V5)
architecture - : DDD4j Boot版本(若使用ddd4j-boot-bom)
ddd4jBootVersion
-
生成项目结构:
- 根据所选类型创建目录结构
- 生成文件(父模块和子模块)
pom.xml - 为每个模块创建文件
package-info.java - 生成、
.gitignore、LICENSE、mvnwmvnw.cmd - 创建包含和
src/main/java的基础目录结构src/test/java
-
保存到项目目录:
- 默认位置: 直接保存到命令执行目录(与命令同级)
- 目录创建: 若项目目录结构不存在则自动创建
- 文件命名: 根据项目类型和模块名称使用描述性命名
For Existing Project Validation
现有项目验证
-
Analyze project structure:
- Scan project directory for Maven modules
- Identify layer structure (interfaces, application, domain, infrastructure)
- Check package naming conventions
- Verify directory organization
-
Identify project type:
- Single-module: Single at root, all layers in one module
pom.xml - Multi-module: Parent with multiple modules, each module has complete layers
pom.xml - Microservices: Multiple services, each with independent structure
- Single-module: Single
-
Validate against standards:
- Check DDD layer compliance
- Verify dependency direction (interfaces → application → domain ← infrastructure)
- Validate package naming ()
{basePackage}.{module}.{layer} - Check for required directories (,
src/main/java)src/test/java - Verify files exist
package-info.java
-
Generate validation report:
- List identified issues
- Provide recommendations
- Suggest fixes for non-compliant structures
-
分析项目结构:
- 扫描项目目录中的Maven模块
- 识别层级结构(interfaces、application、domain、infrastructure)
- 检查包命名规范
- 验证目录组织方式
-
确定项目类型:
- 单体单模块: 根目录下仅有一个,所有层级位于同一模块
pom.xml - 单体多模块: 父包含多个模块,每个模块拥有完整层级
pom.xml - 微服务: 多个服务,每个服务具有独立结构
- 单体单模块: 根目录下仅有一个
-
对照标准验证:
- 检查DDD层级合规性
- 验证依赖方向(interfaces → application → domain ← infrastructure)
- 验证包命名()
{basePackage}.{module}.{layer} - 检查是否存在必需目录(、
src/main/java)src/test/java - 验证文件是否存在
package-info.java
-
生成验证报告:
- 列出识别到的问题
- 提供改进建议
- 针对不合规结构提出修复方案
Output Format and File Saving
输出格式与文件保存
When generating a project structure, follow this response structure:
-
Save the files first: Create the project structure directly in the command execution directory
- The project will be created at the same level as where the command is executed
- Generate all required files and directories (pom.xml, src/, etc.)
- Use the artifactId as the project root directory name
-
Inform the user: Tell them where the files were saved
-
Display the structure: Show the generated directory structure in a code block
Example Response Structure:
- First line: "I've created the DDD project structure and saved it to in the current directory."
./{artifactId}/ - Then show the structure wrapped in a code block:
- Start with: three backticks + + newline
text - Then the directory structure
- End with: three backticks + newline
- Start with: three backticks +
Critical Requirements:
- Always save project files directly to the command execution directory (same level)
- Use artifactId as the project root directory name
- Create the directory structure automatically if it doesn't exist
- Generate complete project structure with all required files
- Follow Maven and DDD conventions strictly
生成项目结构时,请遵循以下响应结构:
-
先保存文件: 直接在命令执行目录中创建项目结构
- 项目将创建在命令执行的同级目录
- 生成所有必需的文件和目录(pom.xml、src/等)
- 使用artifactId作为项目根目录名称
-
通知用户: 告知用户文件保存位置
-
展示结构: 在代码块中显示生成的目录结构
示例响应结构:
- 第一行: "我已创建DDD项目结构并保存到当前目录的路径下。"
./{artifactId}/ - 随后在代码块中展示结构:
- 开头: 三个反引号 + + 换行
text - 然后是目录结构
- 结尾: 三个反引号 + 换行
- 开头: 三个反引号 +
关键要求:
- 始终将项目文件直接保存到命令执行目录(同级)
- 使用artifactId作为项目根目录名称
- 若目录结构不存在则自动创建
- 生成包含所有必需文件的完整项目结构
- 严格遵循Maven和DDD规范
Project Structure Standards
项目结构标准
Package Naming Convention
包命名规范
For multi-module projects:
{basePackage}.{moduleName}.{layerName}Examples:
- - API module, domain layer
io.ddd4j.douyin.api.domain - - API module, application layer
io.ddd4j.douyin.api.application - - API module, interfaces layer
io.ddd4j.douyin.api.interfaces - - API module, infrastructure layer
io.ddd4j.douyin.api.infrastructure
对于多模块项目:
{basePackage}.{moduleName}.{layerName}示例:
- - API模块,领域层
io.ddd4j.douyin.api.domain - - API模块,应用层
io.ddd4j.douyin.api.application - - API模块,接口层
io.ddd4j.douyin.api.interfaces - - API模块,基础设施层
io.ddd4j.douyin.api.infrastructure
Required Files
必需文件
Every module must have:
- - Maven configuration
pom.xml - - Package documentation
src/main/java/{package}/package-info.java - - Test directory structure
src/test/java/ - - Git ignore rules (at root)
.gitignore - - License file (at root)
LICENSE - ,
mvnw- Maven wrapper (at root)mvnw.cmd
每个模块必须包含:
- - Maven配置文件
pom.xml - - 包文档
src/main/java/{package}/package-info.java - - 测试目录结构
src/test/java/ - - Git忽略规则(根目录)
.gitignore - - 许可证文件(根目录)
LICENSE - ,
mvnw- Maven包装器(根目录)mvnw.cmd
Layer Dependencies
层级依赖
Correct dependency direction:
interfaces → application → domain ← infrastructureRules:
- Domain layer must not depend on any other layer
- Infrastructure layer implements domain layer interfaces
- Application layer depends on domain layer
- Interfaces layer depends on application layer
正确的依赖方向:
interfaces → application → domain ← infrastructure规则:
- 领域层不得依赖任何其他层级
- 基础设施层实现领域层接口
- 应用层依赖领域层
- 接口层依赖应用层
Architecture Patterns
架构模式
The skill supports four architecture patterns:
-
DDD Classic Layered Architecture (DDD 经典分层架构)
- Layers: interfaces, application, domain, infrastructure
- Reference: and
docs/1、DDD 经典分层架构目录结构.mdexamples/architecture-patterns.md#ddd-classic
-
Hexagonal Architecture (六边形架构)
- Ports and Adapters pattern
- Reference: and
docs/2、六边形架构详细目录结构参考.mdexamples/architecture-patterns.md#hexagonal
-
Clean Architecture (整洁架构)
- Entities, Use Cases, Interface Adapters
- Reference: and
docs/3、整洁架构详细目录结构参考.mdexamples/architecture-patterns.md#clean
-
COLA V5 (菱形架构)
- Adapter → App → Domain ← Infrastructure
- Reference: and
docs/4、COLA V5 架构详细目录结构参考.mdexamples/architecture-patterns.md#cola-v5
此技能支持四种架构模式:
-
DDD经典分层架构
- 层级: 接口层、应用层、领域层、基础设施层
- 参考: 和
docs/1、DDD 经典分层架构目录结构.mdexamples/architecture-patterns.md#ddd-classic
-
六边形架构
- 端口与适配器模式
- 参考: 和
docs/2、六边形架构详细目录结构参考.mdexamples/architecture-patterns.md#hexagonal
-
整洁架构
- 实体、用例、接口适配器
- 参考: 和
docs/3、整洁架构详细目录结构参考.mdexamples/architecture-patterns.md#clean
-
COLA V5(菱形架构)
- 适配器→应用→领域←基础设施
- 参考: 和
docs/4、COLA V5 架构详细目录结构参考.mdexamples/architecture-patterns.md#cola-v5
Validation Rules
验证规则
When checking existing projects, validate:
-
Structure Compliance:
- ✓ Correct layer organization
- ✓ Proper module separation
- ✓ Package naming conventions
-
Dependency Rules:
- ✓ Domain layer has no external dependencies
- ✓ Infrastructure implements domain interfaces
- ✓ Correct dependency direction
-
File Organization:
- ✓ Required directories exist
- ✓ files present
package-info.java - ✓ Maven configuration correct
-
Naming Conventions:
- ✓ Package names follow convention
- ✓ Module names are descriptive
- ✓ Layer names are standard
检查现有项目时,需验证以下内容:
-
结构合规性:
- ✓ 正确的层级组织
- ✓ 合理的模块拆分
- ✓ 包命名规范
-
依赖规则:
- ✓ 领域层无外部依赖
- ✓ 基础设施层实现领域层接口
- ✓ 正确的依赖方向
-
文件组织:
- ✓ 必需目录存在
- ✓ 文件存在
package-info.java - ✓ Maven配置正确
-
命名规范:
- ✓ 包名符合规范
- ✓ 模块名称具有描述性
- ✓ 层级名称标准
Examples
示例
See the directory for:
examples/- - Complete single-module monolith example
single-module.md - - Complete multi-module monolith example (based on ddd4j-douyin structure)
multi-module.md - - Complete microservices example
microservices.md - - All four architecture patterns with detailed structures
architecture-patterns.md
请查看目录获取:
examples/- - 完整的单体单模块示例
single-module.md - - 完整的单体多模块示例(基于ddd4j-douyin结构)
multi-module.md - - 完整的微服务示例
microservices.md - - 包含四种架构模式的详细结构
architecture-patterns.md
Keywords
关键词
English keywords:
ddd4j, ddd4j-boot, ddd4j project, create ddd4j project, initialize ddd4j project, ddd4j project creator, ddd4j project scaffolding, ddd4j-boot project, ddd4j project structure, ddd4j-boot initialization, ddd4j microservice, ddd4j monolith
Chinese keywords (中文关键词):
ddd4j, ddd4j-boot, ddd4j 项目, 创建 ddd4j 项目, 初始化 ddd4j 项目, ddd4j 项目创建, ddd4j 项目脚手架, ddd4j-boot 项目, ddd4j 项目结构, ddd4j-boot 初始化, ddd4j 微服务, ddd4j 单体应用
IMPORTANT: All keywords must include "ddd4j" to avoid false triggers. Generic terms like "DDD 项目" (DDD project) or "创建项目" (create project) without "ddd4j" should NOT trigger this skill.
英文关键词:
ddd4j, ddd4j-boot, ddd4j project, create ddd4j project, initialize ddd4j project, ddd4j project creator, ddd4j project scaffolding, ddd4j-boot project, ddd4j project structure, ddd4j-boot initialization, ddd4j microservice, ddd4j monolith
中文关键词:
ddd4j, ddd4j-boot, ddd4j 项目, 创建 ddd4j 项目, 初始化 ddd4j 项目, ddd4j 项目创建, ddd4j 项目脚手架, ddd4j-boot 项目, ddd4j 项目结构, ddd4j-boot 初始化, ddd4j 微服务, ddd4j 单体应用
重要提示: 所有关键词必须包含“ddd4j”以避免误触发。未包含“ddd4j”的通用术语,如“DDD 项目”或“创建项目”,请勿触发此技能。