# comp **Repository Path**: cuihui2012/comp ## Basic Information - **Project Name**: comp - **Description**: 微服务底座 - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2022-02-15 - **Last Updated**: 2024-10-11 ## Categories & Tags **Categories**: Uncategorized **Tags**: SpringBoot, SpringCloud, springbootAdmin, SpringSecurity, Swagger ## README # comp - 致力于一套最优雅的后台架构 ## 介绍 --- - **项目介绍** 这是一个java后台的微服务底座,所有模块进行解耦,实现可插拔设计,易上手、易扩展。集成业内优秀开源软件以及自研软件,开箱即用。 - **版本说明** | name | version | | :-------- | :--------| | spring-boot | 2.3.2.RELEASE | | spring-cloud | Hoxton.SR9 | | spring-cloud-alibaba | 2.2.6.RELEASE | | spring-cloud-gateway | 2.2.6.RELEASE | | nacos.config | 0.8.0 | | nacos.client | 1.4.2 | | oauth2/security | 2.2.4.RELEASE | | spring-boot-admin | 2.3.1 | | sentinel-dashboard | 1.8.0 | | xxl-job | 2.3.0 | - **环境说明** jdk:1.8.0_152 mysql:8.0.1-dmr - **技术体系** SpringBoot、SpringCloud(gateway、feign、hystrix等)、SpringCloudAlibaba(nacos、sentinel)、oauth2、SpringSecurity、Swagger2、SpringBootAdmin等 - **项目结构** 所有模块进行解耦,实现可插拔设计 ``` ├─comp --根项目,管理依赖版本号 ├─code-generate --代码生成路径 ├─comp-common-module --公共模块 │ ├─comp-common-cache --缓存模块 │ ├─comp-common-core --公共模块(公共jar包、工具类、公共bean等) │ ├─comp-common-db --数据库模块 │ ├─comp-common-feign --feign远程调用模块 │ ├─comp-common-help --外部辅助包-不被任何项目依赖(例如代码生成、配置文件密文生成等) │ ├─comp-common-log --日志模块 │ ├─comp-common-nginx-parser --nginx配置文件解析工具包,用于nginx-gui项目 │ ├─comp-common-security --微服务security模块 │ ├─comp-common-sentinel --sentinel模块 │ ├─comp-common-swagger --swagger模块 │ └─comp-common-xxl-job --xxl-job模块 ├─comp-common-service --公共服务 │ ├─comp-common-auth --认证授权服务端 │ ├─comp-common-gateway --网关服务端 │ ├─comp-common-monitor --监控服务端 │ ├─comp-common-nginx-gui --nginx图形化管理端 │ ├─comp-common-sentinel-dashboard --sentinel-dashboard服务端 │ └─comp-common-xxl-job-admin --xxl-job服务端 ├─comp-service --所有业务场景下的微服务 │ ├─comp-service-demo1 --微服务demo1 │ └─comp-service-demo2 --微服务demo2 ├─doc --文档 │ ├─nacos --nacos配置文件 │ └─sql --sql脚本 └─logs --日志目录 ``` ## 软件架构 --- 代码架构 ![输入图片说明](https://s3.bmp.ovh/imgs/2022/03/fbc7db013b060d59.jpg) ## 快速开始 --- - **数据库还原** 1. mysql版本采用8.0.1-dmr 2. 分别建库comp、nacos、xxl_job 3. 还原对应[sql文件](https://gitee.com/cuihui2012/comp/tree/master/doc/sql) - **nacos还原** 1. nacos版本采用1.4.2 2. 新建命名空间:dev(4e0ba17a-2728-43d0-9656-71257057a67e) 3. 导入[nacos配置文件](https://gitee.com/cuihui2012/comp/tree/master/doc/nacos) - **项目下载** ``` git clone https://gitee.com/cuihui2012/comp.git cd comp mvn clean install -DskipTests ``` - **配置修改** > 注意:nacos以及数据库相关配置可以直接使用,若使用自己的请按照下文加密后替换。(项目仅供学习交流,请勿随意修改) 1. nacos配置文件说明 | 文件名 | 组| 描述 | | :-------- | :--------|:--------| | comp-application-dev.yaml |DEV_GROUP| 公共配置 | | comp-mysqldb-dev.yaml | DEV_GROUP|数据库配置 | | comp-*-dev.yaml | DEV_GROUP|各微服务私有配置 | | * | SENTINEL_GROUP|sentinel规则持久化配置 | 2. 敏感配置项使用Jasypt加密,见加密工具类[JasyptUtil.java](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-help/src/main/java/com/chj/comp/common/help/util/JasyptUtil.java),秘钥:comp ``` java private final static String KEY = "comp"; private static BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor(); static { basicTextEncryptor.setPassword(KEY); } /** * 加密 * @param text 待加密字符串 * @return */ public static String encryptStr(String text) { String encryptedText = basicTextEncryptor.encrypt(text); return encryptedText; } ``` - **项目启动** 依次启动gateway(网关)、auth(鉴权中心)、monitor(监控中心)、demo1(微服务1)、demo2(微服务2) ![输入图片说明](https://s3.bmp.ovh/imgs/2022/02/88bb60731dbd1927.png) - **效果展示** 1. 服务监控展示,访问链接:[http://localhost:9091/comp/monitor](http://localhost:9091/comp/monitor),用户/密码:admin/since2012 ![输入图片说明](https://s3.bmp.ovh/imgs/2022/02/bb3196284331e96c.png) 2. 日志监控,SpringBootAdmin接入日志 ![输入图片说明](https://s3.bmp.ovh/imgs/2022/02/f54adc4002e47d1c.png) 3. swagger展示,swagger已于gateway整合,访问链接:[http://localhost:9090/doc.html](http://localhost:9090/doc.html) ![输入图片说明](https://s3.bmp.ovh/imgs/2022/02/28298ea8d5b79a30.png) ![输入图片说明](https://s3.bmp.ovh/imgs/2022/02/49f5ebaf76c644b7.png) ## 使用说明 --- - **模块** 1. 缓存模块([comp-common-cache](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-cache/README.md)) 2. 核心模块([comp-common-core](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-core/README.md)) 3. 数据库模块([comp-common-db](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-db/README.md)) 4. feign远程调用模块([comp-common-feign](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-feign/README.md)) 5. 外部辅助包([comp-common-help](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-help/README.md)) 6. 日志模块([comp-common-log](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-log/README.md)) 7. nginx配置文件解析工具包,用于nginx-gui项目([comp-common-nginx-parser](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-nginx-parser/README.md)) 8. 微服务security模块([comp-common-security](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-security/README.md)) 9. sentinel模块([comp-common-sentinel](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-sentinel/README.md)) 10. swagger模块([comp-common-swagger](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-swagger/README.md)) 11. xxl-job模块([comp-common-xxl-job](https://gitee.com/cuihui2012/comp/blob/master/comp-common-module/comp-common-xxl-job/README.md)) - **服务** 1. 认证授权服务端([comp-common-auth](https://gitee.com/cuihui2012/comp/blob/master/comp-common-service/comp-common-auth/README.md)) 2. 网关服务端([comp-common-gateway](https://gitee.com/cuihui2012/comp/blob/master/comp-common-service/comp-common-gateway/README.md)) 3. 监控服务端([comp-common-monitor](https://gitee.com/cuihui2012/comp/blob/master/comp-common-service/comp-common-monitor/README.md)) 4. nginx图形化管理端([comp-common-nginx-gui](https://gitee.com/cuihui2012/comp/blob/master/comp-common-service/comp-common-nginx-gui/README.md)) 5. sentinel-dashboard服务端([comp-common-sentinel-dashboard](https://gitee.com/cuihui2012/comp/blob/master/comp-common-service/comp-common-sentinel-dashboard/README.md)) 6. xxl-job服务端([comp-common-xxl-job-admin](https://gitee.com/cuihui2012/comp/blob/master/comp-common-service/comp-common-xxl-job-admin/README.md)) ## 联系我 --- QQ:751670441