16.SpringCloud實戰項目-Spring Cloud Alibaba 組件簡介

SpringCloud實戰項目全套學習教程連載中

PassJava 學習教程

簡介

  • PassJava-Learning項目是PassJava(佳必過)項目的學習教程。對架構、業務、技術要點進行講解。
  • PassJava 是一款Java面試刷題的開源系統,可以用零碎時間利用小程序查看常見面試題,夯實Java基礎。
  • PassJava 項目可以教會你如何搭建SpringBoot項目,Spring Cloud項目
  • 採用流行的技術,如 SpringBoot、MyBatis、Redis、 MySql、 MongoDB、 RabbitMQ、Elasticsearch,採用Docker容器化部署。

更好的閱讀體驗

文檔連載目錄

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

公衆號

公衆號

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章