Spring Cloud Alibaba的介绍和简单使用说明

1.什么是Spring Cloud Alibaba

1.Spring Cloud的子项目,Spring Cloud是快速构建分布式系统的工具集,即提供了一系列开发分布式应用的工具。
2.致力于提供微服务开发的一站式解决方案。

  • 包含微服务开发的必备组件
  • 基于Spring Cloud,符合Spring Cloud标准
  • 阿里的微服务解决方案
2.Spring Cloud主要功能

参考:https://spring.io/projects/spring-cloud

功能 翻译 选择
Distributed/versioned configuration 分布式/版本化的配置管理 Spring Cloud Config、Consul、Nacos、Zookeeper
Service registration and discovery 服务注册和服务发现 Eureka、Consul、Nacos、Zookeeper
Routing 路由 Zuul、Spring Cloud Gateway
Service-to-service calls 端到端的调用 RestTemplate、Feign
Load balancing 负载均衡 Ribbon
Circuit Breakers 断路器 Hystrix、Sentinel、Resilience4J
Global locks 全局锁 Spring Cloud Cluster(已迁移至Spring Integration)
Leadership election and cluster state 选举与集群状态管理 Spring Cloud Cluster(已迁移至Spring Integration)
Distributed messageing 分布式消息 Spring Cloud Stream+ kafka/RabbitMQ/RocketMQ
3.Spring Cloud常用子项目

Spring Cloud Alibaba的介绍和简单使用说明_第1张图片

4.Spring Cloud Alibaba主要功能

参考:https://github.com/alibaba/spring-cloud-alibaba/blob/2.2.x/README-zh.md

功能 产品 备注
功能 产品 备注
服务限流降级 Sentinel 开源组件
服务注册与发现 Nacos
ANS
开源组件
商业组件
分布式配置管理 Nacos
ACM
开源组件
商业组件
消息驱动能力 Spring Cloud Stream
RocketMQ
开源组件
分布式事务 Seata 开源组件,1.0.0之后可用于生产
阿里云对象存储 OSS 商业组件
分布式任务调度 SchedulerX 商业组件
阿里云短信服务 SMS 商业组件
5.Spring Cloud 版本命名

一般的版本命名都是采用的语义化的版本控制,如"2.1.5.RELEASE",它的含义如下:

2:主版本,第几代
1:次版本,一些功能的增加,但是架构没有太大的变化,是兼容的
5:增量版本,bug修复
RELEASE:正式版,其他的还有,SNAPSHOT:开发版,M:里程碑,一般正式版本发布前都会有几个里程碑版本

Spring Cloud 版本命名较特殊,如"Greenwich RELEASE"是指Greenwich的第一个正式版,后面会继续发布"Greewich SR1",是指第七代版本的第一个Bug修复版本,SR(Service Release)是指BUG修复,Greenwich是指release train(发布列车),是伦敦地铁第七站的名称,其他版本命名:

Angel
Brixton
Camden
Dalston
Edgware
Finchley
Greenwich
Hoxton

6.Spring Cloud生命周期

版本发布规划,参考:https://github.com/spring-cloud/spring-cloud-release/milestones
版本发布记录,参考:https://github.com/spring-cloud/spring-cloud-release/releases
版本终止声明,参考:https://spring.io/projects/spring-cloud#overview

7.版本兼容性
7.1 Spring Cloud Alibaba版本兼容性(目前)

参考:https://github.com/alibaba/spring-cloud-alibaba/wiki/版本说明

毕业版本依赖关系

Spring Cloud Alibaba Version Spring Cloud Version Spring Boot Version
2021.0.1.0 Spring Cloud 2021.0.1 2.6.3
2.2.7.RELEASE Spring Cloud Hoxton.SR12 2.3.12.RELEASE

组件版本关系

Spring Cloud Alibaba Version Sentinel Version Nacos Version RocketMQ Version Dubbo Version Seata Version
2021.0.1.0* 1.8.3 1.4.2 4.9.2 2.7.15 1.4.2
2.2.7.RELEASE 1.8.1 2.0.3 4.6.1 2.7.13 1.3.0
7.2 Spring Cloud 版本兼容性

参考:https://spring.io/projects/spring-cloud#overview

Spring Cloud Alibaba的介绍和简单使用说明_第2张图片

7.3 版本选择建议:

1.不适用非稳定版本/end-of-life版本
2.尽量使用最新一代

  • xxx.RELEASE版本缓一缓,这种属于第一个正式版本,暂时没有得到业间的广泛认可
  • SR2后一般可以用于大规模使用
8.整合Spring Cloud Alibaba

1.pom.xml添加依赖

<dependencyManagement>
    <dependencies>
        
        <dependency>
            <groupId>org.springframework.cloudgroupId>
            <artifactId>spring-cloud-dependenciesartifactId>
            <version>2021.0.1version>
            <type>pomtype>
            <scope>importscope>
        dependency>
        
        <dependency>
            <groupId>com.alibaba.cloudgroupId>
            <artifactId>spring-cloud-alibaba-dependenciesartifactId>
            <version>2021.0.1.0version>
            <type>pomtype>
            <scope>importscope>
        dependency>
    dependencies>
dependencyManagement>

2.引入Spring Cloud Alibaba的Nacos组件

<dependencies>
	<dependency>
        <groupId>org.springframework.cloudgroupId>
        <artifactId>spring-cloud-starter-alibaba-nacos-discoveryartifactId>
        <version>0.9.0.RELEASEversion>
    dependency>
dependencies>

3.构建项目

mvn clean install

结果:
Spring Cloud Alibaba的介绍和简单使用说明_第3张图片

注意:在构建时候如果出现Nacos版本错误,可以在Maven仓库选择对应版本,参考地址:https://developer.aliyun.com/mvn/search

(此文完 )

你可能感兴趣的:(+,Spring,Cloud,spring,cloud,java,spring)