[TOC]
# 简介
>[info] 简单说明企业微服务平台maven结构
## 企业微服务平台maven结构
>[info] 采用单体多模块的方式构建的maven项目,目录结构如下:
newocp/
├── doc nacos相关配置文件
├── sql 项目初始化数据库文件
├── business-center 业务中心
│ ├── batch-center 基于分区批处理相关技术
│ ├── codegen-center 代码生成器相关配置
│ ├── file-center 基于事件驱动的文件中心
│ ├── sms-center 短信中心
│ └── user-center 用户中心
├── inner-intergration 内部集成二方包
│ ├── banner-spring-boot-starter 启动banner设置工具包
│ ├── base-spring-boot-starter 内部基础工具包
│ ├── common-spring-boot-starter 过滤器等工具包
│ ├── config-spring-boot-starter 通用配置工具包
│ ├── db-spring-boot-starter 数据库封装工具包
│ ├── flyway-spring-boot-starter flyway版本控制工具包
│ ├── jpush-spring-boot-starter 极光推送工具包
│ ├── loadbalancer-spring-boot-starter 负载均衡工具包
│ ├── log-spring-boot-starter 日志工具包
│ ├── oss-spring-boot-starter aws s3 oss工具包
│ ├── redis-spring-boot-starter redis工具包
│ ├── rules-spring-boot-starter 简单规则引擎工具包
│ ├── sentinel-spring-boot-starter 熔断限流工具包
│ ├── swagger-spring-boot-starter swagger工具包
│ ├── uaa-client-spring-boot-starter 资源服务器抽象工具包
│ ├── uaa-server-spring-boot-starter 认证服务器抽象工具包
│ └── uid-spring-boot-starter uid生成工具包
├── job-center 基于nacos改造的xxl-job调度中心
│ ├── job-admin 调度器
│ ├── job-core 调度执行内核
│ └── job-demo 执行器
├── monitor-center 监控中心
│ ├── admin-server spring boot admin
│ ├── log-center 日志中心
│ └── sentienl-server sentinel控制台
│ ├── sentinel-dashboard
│ └── sentinel-tokenserver
├── new-api-gateway spring cloud gateway网关
├── oauth-center oauth鉴权中心
│ ├── auth-server oauth认证中心
│ ├── auth-sso oauthsso demo
├── register-center 注册中心
│ └── nacos-server nacos
└── web-portal web门户
└── back-center 后台管理入口
## 什么是单体仓库
![](https://img.kancloud.cn/cf/d9/cfd928927d9af5f457023b6ada69a994_1201x613.png)
## 单体仓库多模块的好处
* 统一的规范,语言,和IDE带来的是结构的完整稳定。
* 标准化的开发流程,规避很多不必要的冲突与错误。
## pom 简单介绍
1. profiles默认环境初始化变量
注意平台pom文件采用了默认的profiles配置方式,具体参考如下:
![](https://img.kancloud.cn/7a/78/7a78431cecc0cf913282fb341033b0c3_1937x538.png)
采用此方式的好处是在开发环境中,平台默认会读取
application-dev.properties作为环境变量,初始化项目中的数据库等初始化相关信息,达到统一平台配置功能
![](https://img.kancloud.cn/a1/35/a135659d7c4a0bc70b27b52bf5d319b1_1603x959.png)
需要切换环境时,还是采用mvn clean package -Ptest
2. resource动态修改环境
注意平台filtering相关配置
![](https://img.kancloud.cn/14/96/1496ea91bb71b6c5a5d061664afec47a_1518x519.png)
采用此方式的好处是maven可以动态初始化变量
![](https://img.kancloud.cn/0a/91/0a91d93c4bc0852b584e559ab585c7d1_1666x971.png)
![](https://img.kancloud.cn/5d/90/5d90a643c907cca2ced7a355e73b5b9f_1458x429.png)
**特别需要注意是是jks相关证书不能设置filtering=true**
3. 动态版本发布
注意平台revision参数
![](https://img.kancloud.cn/bc/1b/bc1b48c59bc5f50da6d2534505c55aaf_1778x492.png)
```
<properties>
<revision>2.0.2</revision>
</properties>
```
**flatten-maven-plugin动态替换平台版本参数**
## maven 编译
![](https://img.kancloud.cn/46/4f/464fcde70e243c41d8b00d5740d5956a_1673x1013.png)
```
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for open-capacity-platform 2.0.2:
[INFO]
[INFO] open-capacity-platform ............................. SUCCESS [ 1.704 s]
[INFO] inner-intergration ................................. SUCCESS [ 0.186 s]
[INFO] banner-spring-boot-starter ......................... SUCCESS [ 1.439 s]
[INFO] log-spring-boot-starter ............................ SUCCESS [ 5.138 s]
[INFO] base-spring-boot-starter ........................... SUCCESS [ 31.524 s]
[INFO] redis-spring-boot-starter .......................... SUCCESS [ 3.451 s]
[INFO] common-spring-boot-starter ......................... SUCCESS [ 3.414 s]
[INFO] config-spring-boot-starter ......................... SUCCESS [ 0.562 s]
[INFO] db-spring-boot-starter ............................. SUCCESS [ 7.871 s]
[INFO] flyway-spring-boot-starter ......................... SUCCESS [ 2.501 s]
[INFO] swagger-spring-boot-starter ........................ SUCCESS [ 3.034 s]
[INFO] uaa-client-spring-boot-starter ..................... SUCCESS [ 5.682 s]
[INFO] uaa-server-spring-boot-starter ..................... SUCCESS [ 6.045 s]
[INFO] loadbalancer-spring-boot-starter ................... SUCCESS [ 3.105 s]
[INFO] sentinel-spring-boot-starter ....................... SUCCESS [ 3.320 s]
[INFO] rules-spring-boot-starter .......................... SUCCESS [ 2.653 s]
[INFO] oss-spring-boot-starter ............................ SUCCESS [ 2.012 s]
[INFO] uid-spring-boot-starter ............................ SUCCESS [ 4.674 s]
[INFO] jpush-spring-boot-starter .......................... SUCCESS [ 2.924 s]
[INFO] register-center .................................... SUCCESS [ 0.159 s]
[INFO] nacos-server ....................................... SUCCESS [ 11.307 s]
[INFO] oauth-center ....................................... SUCCESS [ 0.117 s]
[INFO] auth-server ........................................ SUCCESS [ 11.748 s]
[INFO] auth-sso ........................................... SUCCESS [ 2.300 s]
[INFO] business-center .................................... SUCCESS [ 0.106 s]
[INFO] user-center ........................................ SUCCESS [ 8.350 s]
[INFO] batch-center ....................................... SUCCESS [ 4.517 s]
[INFO] file-center ........................................ SUCCESS [ 6.843 s]
[INFO] sms-center ......................................... SUCCESS [ 6.055 s]
[INFO] codegen-center ..................................... SUCCESS [ 5.559 s]
[INFO] tuning-center ...................................... SUCCESS [ 0.123 s]
[INFO] test-db-spring-boot-starter ........................ SUCCESS [ 6.137 s]
[INFO] test-rabbitmq-cloud-stream-starter ................. SUCCESS [ 0.145 s]
[INFO] producing .......................................... SUCCESS [ 2.114 s]
[INFO] comsumer ........................................... SUCCESS [ 2.112 s]
[INFO] test-redis-spring-boot-starter ..................... SUCCESS [ 1.975 s]
[INFO] test-disruptor-spring-boot-starter ................. SUCCESS [ 3.294 s]
[INFO] test-log-spring-boot-starter ....................... SUCCESS [ 2.314 s]
[INFO] test-jmh-spring-boot-starter ....................... SUCCESS [ 4.621 s]
[INFO] test-rule-spring-boot-starter ...................... SUCCESS [ 5.053 s]
[INFO] test-generator-starter ............................. SUCCESS [ 1.309 s]
[INFO] monitor-center ..................................... SUCCESS [ 0.115 s]
[INFO] admin-server ....................................... SUCCESS [ 2.527 s]
[INFO] sentienl-server .................................... SUCCESS [ 0.113 s]
[INFO] sentinel-dashboard ................................. SUCCESS [ 7.155 s]
[INFO] sentinel-tokenserver ............................... SUCCESS [ 1.461 s]
[INFO] log-center ......................................... SUCCESS [ 6.461 s]
[INFO] new-api-gateway .................................... SUCCESS [ 8.227 s]
[INFO] job-center ......................................... SUCCESS [ 0.178 s]
[INFO] job-core ........................................... SUCCESS [ 5.127 s]
[INFO] job-admin .......................................... SUCCESS [ 9.380 s]
[INFO] job-demo ........................................... SUCCESS [ 3.104 s]
[INFO] web-portal ......................................... SUCCESS [ 0.101 s]
[INFO] back-center ........................................ SUCCESS [ 6.689 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:49 min
[INFO] Finished at: 2023-02-26T11:02:31+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.
Process finished with exit code 0
```
## 统一的依赖管理
温馨提示
当前 Spring Cloud Alibaba 的2021.1版本基于 2020.0.5开发, Spring Boot 版本使用 2.5.14,注意此版本号,以免发生意想不到的问题(比如服务无法注册到服务器)
![](https://img.kancloud.cn/3b/62/3b62bec0935a720d07c2a1c633efd7eb_1789x814.png)
Spring Cloud Alibaba 项目都是基于 Spring Cloud,而 Spring Cloud 项目又是基于 Spring Boot 进行开发,并且都是使用 Maven 做项目管理工具。在实际开发中,我们一般都会创建一个依赖管理项目作为 Maven 的 Parent 项目使用,这样做可以极大的方便我们对 Jar 包版本的统一管理。
![](https://img.kancloud.cn/f2/e2/f2e209a18ccfe051a7e0547d7b24ea81_1826x1136.png)
- 01.前言
- 02.快速开始
- 01.maven构建项目
- 02.安装mysql数据库
- 03.安装redis缓存中间件
- 04.快速启动框架
- 03.总体流程
- 01.架构设计图
- 02.oauth接口
- 03.功能介绍
- 04.部署细节
- 04.模块详解
- 01.基础介绍
- 02.自定义db-spring-boot-starter
- 03.自定义log-spring-boot-starter
- 04.自定义redis-spring-boot-starter
- 05.自定义base-spring-boot-starter
- 06.自定义common-spring-boot-starter
- 07.自定义loadbalancer-spring-boot-starter
- 08.自定义swagger-spring-boot-starter
- 09.自定义uaa-client-spring-boot-starter
- 10.自定义uaa-server-spring-boot-starter
- 11.自定义oss-spring-boot-starter
- 12.自定义sentinel-spring-boot-starter
- 05.服务详解
- 01.nacos-server
- 02.auth-server
- 03.user-center
- 04.new-api-gateway
- 05.file-center
- 06.log-center
- 07.back-center
- 08.auth-sso模块
- 09.admin-server
- 10.job-center
- 06.系统安全
- 01.非法字符漏洞攻击
- 02.防重放攻击
- 03.代码审计
- 04.Xray扫洞
- 05.混沌工程质量保证
- 07.生产部署K8S
- 01.基本环境安装
- 02.基本组件安装
- 03.集群验证
- 04.安装Metrics Server
- 05.安装容器平台
- 06.Ingress网关
- 07.metalb负载均衡器
- 08.容器平台集群
- 08.K8S资源练习
- 01.Deployment
- 02.StatefulSet
- 03.DaemonSet
- 04.redis集群服务
- 05.elasticsearch集群
- 06.rocketmq部署
- 09.生产容器化部署
- 01.nacos集群部署
- 02.user-center服务
- 03.auth-server服务
- 04.new-api-gateway服务
- 技术交流