doc(archetype): 添加使用教程

This commit is contained in:
15858193327
2020-10-16 23:16:21 +08:00
parent cca42f72de
commit 7ead16f2f3
13 changed files with 47 additions and 14 deletions

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

View File

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

BIN
img/archetype/idea/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

BIN
img/archetype/idea/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
img/archetype/idea/3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
img/archetype/idea/4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
img/archetype/idea/5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

BIN
img/archetype/idea/6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
img/archetype/idea/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

BIN
img/archetype/idea/new.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

View File

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 182 KiB

View File

@@ -6,7 +6,7 @@
## 诞生背景
项目中大都是分模块开发,一个模块一个工程,通过一个外层工程管理所有模块,充分利用maven的`聚合``继承`的特性来减少项目管理的成本。
项目中大都是分模块开发,一个模块一个工程,通过一个外层工程管理所有模块,`Shoulder` 充分汲取 `领域驱动开发DDD` 概念的优点,合理利用 `maven` `聚合``继承`的特性来减少项目管理的成本。
> 聚合是为了管理多模块build继承是方便依赖管理
@@ -17,6 +17,9 @@
下面以 IDEA 为例,介绍如何通过 `shoulder-platform-archetype` 快速创建一个引入了`shoulder`的 spring boot web 工程
### 新建工程
![选择shoulder](../../img/archetype/idea/new.png)
### 添加 shoulder 的 archetype
第一次使用时需要添加,以后都不用这一步咯,`version` 不同,创建的也可能不同哦
@@ -27,38 +30,68 @@ artifactId shoulder-platform-archetype
version 1.0-SNAPSHOT
```
![添加 shoulder 的 archetype](../doc/img/archetype/idea/add.png)
![添加 shoulder-platform 的 archetype](../../img/archetype/idea/add.png)
### 基于 shoulder 提供的模板创建 maven 工程
#### 选择shoulder
![选择shoulder](../doc/img/archetype/idea/1.png)
![选择shoulder](../../img/archetype/idea/1.png)
#### 输入 gourpId、artifactId
![输入 gourpId、artifactId](../doc/img/archetype/idea/2.png)
#### 输入 groupId、artifactId
![输入 gourpId、artifactId](../../img/archetype/idea/2.png)
> groupId 通常是本次项目的空间地址,以倒域名形式呈现,如 org.shoulder
> artifactId 则为本项目的唯一标识,通常为单词或多个单词的缩写,如 `education` 可以表示 `教务系统` ; `ups` 可以表示 `user privilege service` `用户权限服务`
#### 【可选】 调整模板的值
所有属性以及默认值见文末的 `模板属性表`
所有属性以及默认值见文末的 `模板属性表`,可直接下一步
![输入覆盖模板的值](../doc/img/archetype/idea/3.png)
![输入覆盖模板的值](../../img/archetype/idea/3.png)
#### 完成创建
![完成创建](../doc/img/archetype/idea/4.png)
点击完成
![完成创建](../../img/archetype/idea/4.png)
#### 等待创建完毕
![等待创建完毕](../doc/img/archetype/idea/5.png)
- 这一步可能会特别慢原因未设置maven本地缓存访问官网下载大量文件。解决方式参考 [IDEA 创建maven工程 create from archetype 很慢](https://blog.csdn.net/qq_35425070/article/details/108958087)
- 创建完毕后,我们需要 `reimport maven` 依赖,这里我们直接点击自动更新(`auto reimport`
#### 启动运行
![启动运行](../doc/img/archetype/idea/6.png)
![等待创建完毕](../../img/archetype/idea/5.png)
- 这一步通常只需要几秒中国时间但也可能特别慢原因未设置maven本地缓存访问官网下载大量文件。解决方式参考 [IDEA 创建maven工程 create from archetype 很慢](https://blog.csdn.net/qq_35425070/article/details/108958087)
- 创建完毕后,我们需要触发 `reimport maven` 告诉 IDE 重新导入`pom.xml`中声明的依赖库。
可以访问 DemoController [http://localhost:8080/demo/test](http://localhost:8080/demo/test) 查看一下
#### 查看包目录结构
由于 `maven` 多模块工程并不像单个模块一样一眼就看个透,第一次使用时,我们需要熟悉一下工程目录
![工程目录](../../img/archetype/idea/6.png)
---
## 工程目录结构介绍:
* `infrastructure` : `基础设施层` 最下层模块,向上层工程提供坚实牢固的地基,隔离技术选型,将具体技术以插件形式织入系统代码,即使技术变更也不容易侵害业务代码。
* 该层默认包含了缓存、存储的隔离设定、可以根据自身需求,考虑隔离消息队列、搜索引擎、定时任务等。
* `reference` : `调用边界层` 存放了调用其他应用接口的实现,其中可包含多个模块。
* `reference-xxx` : `调用 xxx 系统接口边界层` (可选)存放 xxx 应用提供接口的定义、DTO定义、能力激活。
* `reference-adptor` : `调用边界防腐层`(可选)在该模块处理第三方数据与自身系统定义的模型转换、抽取、包路径、类名隔离、限流、熔断、降级策略。
* `core` : `核心模块` 是你的应用系统中公共、基础模块,如错误码、业务定义、常量、枚举、通用工具。
* `modules` : `具体业务模块` (可选)一个系统中可能包含多类小业务,可以在这里按照业务划分,分为不同的业务,如 `NACOS` 包含 `naming``config` 两个子模块。
* `provider` : `对外能力提供层`(可选)向外提供功能,如供其他服务调用的 restful api 接口
* `web` : `web 模块`(可选)向前端提供接口,如:与浏览器交互。注意前后分离架构里通常不会有该模块,因为调用链改为:浏览器 - 前端服务 - 后端 api 接口。
* `start` : `启动模块`,可以在这里决定将哪些能力组合打包,配置文件等。
![目录结构](../../img/archetype/projectAndModule.png)
---