springCloud簡介
Spring cloud是一個基於Spring Boot實現的服務治理工具包,在微服務架構中用於管理和協調服務的
微服務:就是把一個單體項目,拆分為多個微服務,每個微服務可以獨立技術選型,獨立開發,獨立部署,獨立運維.並且多個服務相互協調,相互配合,最終完成用戶的價值.
Spring Cloud是一系列框架的有序集合。它利用Spring Boot的開發便利性巧妙地簡化了分布式系統基礎設施的開發,如服務發現注冊、配置中心、消息總線、負載均衡、斷路器、數據監控等,都可以用Spring Boot的開發風格做到一鍵啟動和部署
Spring Cloud特點:
1:約定優於配置。
2:開箱即用、快速啟動。
3:適用於各種環境。
4:輕量級的組件。
5:組件支持豐富,功能齊全。
優點:
1、可以按需伸縮
5、服務拆分粒度更細,有利於資源重復利用,有利於提高開發效率
2、可以更精准的制定優化服務方案,提高系統的可維護性
3、微服務架構采用去中心化思想,服務之間采用Restful等輕量級通訊,比ESB更輕量
4、適於互聯網時代,產品迭代周期更短
缺點:
1、微服務過多,治理成本高,不利於維護系統
2、分布式系統開發的成本高(容錯,分布式事務等)對團隊挑戰大
五大重要組件
服務發現——Netflix Eureka
客服端負載均衡——Netflix Ribbon/Feign
服務網關——Netflix Zuul
斷路器——Netflix Hystrix
分布式配置——Spring Cloud Config
springCloud與SpringBoot版本對應關系:
官網版本對應:https://start.spring.io/actuator/info
"Finchley.M2": "Spring Boot >=2.0.0.M3 and <2.0.0.M5", "Finchley.M3": "Spring Boot >=2.0.0.M5 and <=2.0.0.M5", "Finchley.M4": "Spring Boot >=2.0.0.M6 and <=2.0.0.M6", "Finchley.M5": "Spring Boot >=2.0.0.M7 and <=2.0.0.M7", "Finchley.M6": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1", "Finchley.M7": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2", "Finchley.M9": "Spring Boot >=2.0.0.RELEASE and <=2.0.0.RELEASE", "Finchley.RC1": "Spring Boot >=2.0.1.RELEASE and <2.0.2.RELEASE", "Finchley.RC2": "Spring Boot >=2.0.2.RELEASE and <2.0.3.RELEASE", "Finchley.SR4": "Spring Boot >=2.0.3.RELEASE and <2.0.999.BUILD-SNAPSHOT", "Finchley.BUILD-SNAPSHOT": "Spring Boot >=2.0.999.BUILD-SNAPSHOT and <2.1.0.M3", "Greenwich.M1": "Spring Boot >=2.1.0.M3 and <2.1.0.RELEASE", "Greenwich.SR5": "Spring Boot >=2.1.0.RELEASE and <2.1.14.BUILD-SNAPSHOT", "Greenwich.BUILD-SNAPSHOT": "Spring Boot >=2.1.14.BUILD-SNAPSHOT and <2.2.0.M4", "Hoxton.SR3": "Spring Boot >=2.2.0.M4 and <2.3.0.BUILD-SNAPSHOT", "Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.3.0.BUILD-SNAPSHOT"
2020springCloud版本選型:
maven
<!--spring boot2.2.2-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--spring cloud Hoxton.SR1-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--spring cloud alibaba 2.1.0.RELEASE-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>2.1.0.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>