SpringCloud實戰項目全套學習教程連載中
PassJava 學習教程
簡介
- PassJava-Learning項目是PassJava(佳必過)項目的學習教程。對架構、業務、技術要點進行講解。
- PassJava 是一款Java
面試刷題
的開源系統,可以用零碎時間利用小程序查看常見面試題,夯實Java基礎。 - PassJava 項目可以教會你如何搭建SpringBoot項目,Spring Cloud項目
- 采用流行的技術,如 SpringBoot、MyBatis、Redis、 MySql、 MongoDB、 RabbitMQ、Elasticsearch,采用Docker容器化部署。
更好的閱讀體驗
文檔連載目錄
- 打造一款 刷Java 知識的小程序
- 打造一款 刷Java 知識的小程序(二)
- 01.五分鍾搞懂分布式基礎概念
- 02.快速搭建Linux環境-運維必備
- 03.配置虛擬機網絡
- 04.安裝Docker
- 05.Docker安裝mysql
- 06.Docker安裝redis
- 07.本地開發環境配置
- 08.配置Git
- 09.初始化項目和添加微服務
- 10.PassJava-微服務划分圖
- 11.初始化數據庫和表
- 12.搭建管理后台
- 13.自動生成前后端代碼
- 14.整合MyBatis-Plus實現CRUD
- 15.生成所有微服務的CRUD代碼
- 16.Spring Cloud Alibaba 組件簡介
SpringCloud Alibaba 組件簡介
1.SpringCloud Alibaba概述
Spring Cloud Alibaba 致力於提供微服務開發的一站式解決方案。此項目包含開發分布式應用微服務的必需組件,方便開發者通過 Spring Cloud 編程模型輕松使用這些組件來開發分布式應用服務。
依托 Spring Cloud Alibaba,您只需要添加一些注解和少量配置,就可以將 Spring Cloud 應用接入阿里微服務解決方案,通過阿里中間件來迅速搭建分布式應用系統。
Github:https://github.com/alibaba/spring-cloud-alibaba
Spring Cloud的幾大痛點
- 部分組件停止維護和更新,有問題也不易解決
- 部分環境搭建起來比較復雜,沒有非常友好的可視化界面
- 配置相對來說復雜,需要較高的學習成本
Spring Cloud Alibaba的優勢
- 阿里經歷過了時間的考驗
- 設計合理
- 擁有不錯的可視化界面,方便運維監控和排查問題
- 環境搭建和配置簡單,學習成本低
PassJava項目搭配SpringCloud Alibaba技術的搭配方案
描述 | Spring Cloud | Spring Cloud Alibaba | 組合選用 |
---|---|---|---|
服務發現組件 | Eureka(停止維護)服務發現組件 | Nacos 注冊中心 | Spring Cloud Alibaba - Nacos |
配置中心組件 | Spring Cloud Config 配置中心 | Nacos 配置中心 | Spring Cloud Alibaba - Nacos |
斷路保護組件 | Hystrix 斷路保護 | Sentinel 服務容錯 | Spring Cloud Alibaba - Sentinel |
鏈路追蹤組件 | Sleuth 調用鏈監控 | / | Spring Cloud - Sleuth |
負載均衡組件 | Ribbon | / | Spring Cloud - Ribbon |
遠程調用組件 | OpenFeign (HTTP+JSON) | Dubbo(RPC框架) | Spring Cloud - OpenFeign |
分布式事務 | / | Seata 分布式事務 | Spring Cloud Alibaba - Seata |
API 網關 | Gateway | / | Spring Cloud - Gateway |
最后技術選型:
Spring Cloud Alibaba - Nacos 實現注冊中心
Spring Cloud Alibaba - Nacos 實現配置中心
Spring Cloud Alibaba - Sentinel 實現服務容錯
Spring Cloud Alibaba - Seata 實現分布式事務
Spring Cloud - Ribbon 實現負載均衡
Spring Cloud - Feign 實現遠程調用
Spring Cloud - Gateway API網關
Spring Cloud - Sleuth 實現調用鏈監控
2.Spring Cloud Alibaba版本
項目的版本號格式為 x.x.x 的形式,其中 x 的數值類型為數字,從 0 開始取值,且不限於 0~9 這個范圍。項目處於孵化器階段時,第一位版本號固定使用 0,即版本號為 0.x.x 的格式。
由於 Spring Boot 1 和 Spring Boot 2 在 Actuator 模塊的接口和注解有很大的變更,且 spring-cloud-commons 從 1.x.x 版本升級到 2.0.0 版本也有較大的變更,因此阿里采取跟 SpringBoot 版本號一致的版本:
- 1.5.x 版本適用於 Spring Boot 1.5.x
- 2.0.x 版本適用於 Spring Boot 2.0.x
- 2.1.x 版本適用於 Spring Boot 2.1.x
- 2.2.x 版本適用於 Spring Boot 2.2.x
Spring Cloud Alibaba 版本和Spring Cloud 和Spring Boot 版本兼容性列表
Spring Cloud 版本 | Spring Cloud Alibaba 版本 | Spring Boot 版本 |
---|---|---|
Spring Cloud Hoxton.SR3 | 2.2.x.RELEASE | 2.2.x.RELEASE |
Spring Cloud Greenwich | 2.1.x.RELEASE | 2.1.x.RELEASE |
Spring Cloud Finchley | 2.0.x.RELEASE | 2.0.x.RELEASE |
Spring Cloud Edgware | 1.5.x.RELEASE | 1.5.x.RELEASE |
我們采用Spring Cloud Hoxton.SR3
, Spring Cloud Alibaba 2.2.0.RELEASE
, Spring Boot 2.2.6 RELEASE
PassJava-Common的pom.xml文件引入Spring Cloud Alibaba依賴
<dependencyManagement>
<dependencies>
<!-- Spring Cloud Alibaba 依賴 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.2.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
代碼地址
https://github.com/Jackson0714/PassJava-Platform