前言
- 工具:IntelliJ IDEA 2020.3
- JDK: 1.8
- 项目构建:Maven
- 技术选型:Spring Boot + Spring Cloud + Spring Cloud Alibaba
- 工程结构:
|_parent/
|_user-server/
|_order-server/
|_pom.xml
1. 先创建父工程项目
- 选择 Spring Initializr

- 填写选择项目信息, Next,直到 Finish

- 修改父工程 pom.xml
- 删除 parent/src 目录
- 去掉 <parent></parent> 依赖
- 指定打包类型为: pom
- 添加 Spring Boot,Spring Cloud,Spring Cloud Alibaba 版本(这里会有坑:Boot与Cloud版本选择,编译报错,请看最后参考)

- 父工程构建完成,只修改 pom.xml 文件
2. 创建 user-server 项目
- New Module

- 填写项目信息

- 查看模块路径是否正确,路径正确直接 Finish

- user-server/pom.xml 文件,修改<parent></parent>

- parent/pom.xml,添加 module

- 运行 user-server

3. 创建 order-server 项目
- 以同样的方式创建 order-server,整个项目结构如下:

至此,多模块项目搭建完成,源码在这里
网友评论