Spring Cloud Alibaba生态入门

背景说明

Spring Cloud 自 2015 年 3 月推出之后,很快就在 Java 微服务生态中,成为开发人员的首选技术栈。Spring Cloud 在 Spring Boot 的基础上,保留 Java 开发习惯,加入分布式特性,提供了一系列通用工具来帮助开发者在分布式系统里快速构建一些常见模式,现在已成为使用范围最广的微服务架构之一。

Spring Cloud是基于Spring Boot的一整套实现微服务的框架。他提供了微服务开发所需的配置管理、服务发现、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等组件。最重要的是,跟spring boot框架一起使用的话,会让你开发微服务架构的云服务非常好的方便,Spring Cloud包含了非常多的子框架,其中,Spring Cloud netflix是其中一套框架,由Netflix开发后来又并入Spring Cloud大家庭,它主要提供的模块包括:服务发现、断路器和监控、智能路由、客户端负载均衡等。

Spring Cloud Netflix是最受欢迎的项目,它是Spring Cloud的一部分,但是Pivotal宣布大部分Spring Cloud Netflix模块正在进入维护模式,从Spring Cloud Greenwich发布列车开始,Netflix OSS,Archaius,Hystrix,Ribbon和Zuul正在进入维护模式。这意味着不会向这些模块添加任何新功能,Spring Cloud团队只会执行一些错误修复并修复安全问题。维护模式不包括仍受支持的Eureka模块。

2017 年,阿里基于 Spring Cloud 推出的 Spring Cloud Alibaba 正式入驻 Spring Cloud 孵化器,并在 2019 年 7 月正式毕业,Spring Cloud Alibaba是基于Spring Cloud Common的规范实现,致力于提供微服务开发一站式解决方案,此项目包括开发分布式应用微服务的必需组件,方便开发者通过Spring Cloud编程模型轻松使用这些组件来开发分布式应用服务,而Spring Cloud Alibaba的各个微服务组件依赖于Spring Cloud Alibaba自身。

https://www.oschina.net/question/4489239_2321891

拥抱理由

  1. Spring Cloud部分组件停止维护和更新,亟需下一个大厂接盘生态
  2. 阿里使用过的组件经历了大量考验,具备较高的稳定性和可信度
  3. 背靠阿里云,盈利模式较好,具备长期维护发展的潜力和实力

解决方案

工程创建

脚手架提供了通过在线网站创建项目

https://start.aliyun.com/bootstrap.html
https://start.spring.io/

阿里云效提供的脚手架提供了Spring Cloud Alibaba相关的依赖并解决了版本的依赖关系,针对选用Spring Cloud Alibaba生态建议使用
建议安装插件Alibaba Cloud Toolkit提供了项目创建入口,不需要再访问网页

版本依赖

https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-dependencies
https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-dependencies
https://mvnrepository.com/artifact/com.alibaba.cloud/spring-cloud-alibaba-dependencies

选中一个指定版本,然后页面往下拉找到Managed Dependencies即可看到依赖的版本明细信息

阿里云提供Maven的GAV查询和下载: https://maven.aliyun.com/mvn/search

开源地址

https://github.com/alibaba/spring-cloud-alibaba

官方文档

https://spring.io/projects/spring-cloud-alibaba
https://github.com/alibaba/spring-cloud-alibaba/blob/master/README-zh.md
https://github.com/alibaba/spring-cloud-alibaba/wiki/版本说明

版本演进

孵化版本

孵化版本为早期版本,不可用于生产环境,可以阅读源码查看实现思路

Spring Boot VersionSpring Cloud VersionSpring Cloud Alibaba Version备注说明
1.5.X.RELEASESpring Cloud Edgware0.1.X.RELEASE最低支持 Edgware.SR5 版本
2.0.X.RELEASESpring Cloud Finchley0.2.X.RELEASE
2.1.X.RELEASESpring Cloud Greenwich0.9.0.RELEASE

Spring Cloud Alibaba BOM 包含了它所使用的所有依赖的版本。

<dependencyManagement>
	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-alibaba-dependencies</artifactId>
			<version>0.9.0.RELEASE</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>	
	</dependencies>
</dependencyManagement>
毕业版本
Spring Boot VersionSpring Cloud VersionSpring Cloud Alibaba Version备注说明
1.5.X.RELEASESpring Cloud Edgware1.5.1.RELEASE停止维护,建议升级
2.0.X.RELEASESpring Cloud Finchley2.0.4.RELEASE停止维护,建议升级
2.1.X.RELEASESpring Cloud Greenwich2.1.2.RELEASE
2.2.X.RELEASESpring Cloud Hoxton.RELEASE2.2.0.RELEASE
2.2.5.RELEASESpring Cloud Hoxton.SR32.2.1.RELEASE
2.1.13.RELEASESpring Cloud Greenwich.SR62.1.4.RELEASE
2.2.5.RELEASESpring Cloud Hoxton.SR82.3.2.RELEASE
2.4.2.RELEASESpring Cloud 2020.02021.1

Spring Cloud Alibaba BOM 包含了它所使用的所有依赖的版本。

<dependencyManagement>
	<dependencies>
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-alibaba-dependencies</artifactId>
            <version>2.2.5.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
	</dependencies>
</dependencyManagement>

组件版本

Spring Cloud Alibaba VersionSentinel VersionNacos VersionRocketMQ VersionDubbo VersionSeata Version
2.1.0.RELEASE or 2.0.0.RELEASE or 1.5.0.RELEASE1.6.31.1.14.4.02.7.30.7.1
2.1.1.RELEASE or 2.0.1.RELEASE or 1.5.1.RELEASE1.7.01.1.44.4.02.7.30.9.0
2.2.0.RELEASE1.7.11.1.44.4.02.7.4.11.0.0
2.2.1.RELEASE or 2.1.2.RELEASE or 2.0.2.RELEASE1.7.11.2.14.4.02.7.61.2.0
2.2.3.RELEASE or 2.1.3.RELEASE or 2.0.3.RELEASE1.8.01.3.34.4.02.7.81.3.0
2.2.5.RELEASE or 2.1.4.RELEASE or 2.0.4.RELEASE1.8.01.4.14.4.02.7.81.3.0

补充信息

Spring Cloud里程碑

https://github.com/spring-cloud/spring-cloud-release/milestones

Spring Cloud版本演进

https://github.com/spring-cloud/spring-cloud-release/releases

官方脚手架依赖关系

打开浏览器访问网址查看最新依赖关系:https://start.spring.io/actuator/info

{
    "git": {
        "branch": "6453e15b56f143d46fdd7eb4f4e3b6df13a8bb10",
        "commit": {
            "id": "6453e15",
            "time": "2021-06-14T12:42:48Z"
        }
    },
    "build": {
        "version": "0.0.1-SNAPSHOT",
        "artifact": "start-site",
        "versions": {
            "spring-boot": "2.5.1",
            "initializr": "0.11.0-SNAPSHOT"
        },
        "name": "start.spring.io website",
        "time": "2021-06-14T12:44:06.395Z",
        "group": "io.spring.start"
    },
    "bom-ranges": {
        "azure": {
            "2.2.4": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
            "3.5.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1"
        },
        "codecentric-spring-boot-admin": {
            "2.2.4": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "2.3.1": "Spring Boot >=2.3.0.M1 and <2.5.0-M1"
        },
        "solace-spring-boot": {
            "1.0.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "1.1.0": "Spring Boot >=2.3.0.M1 and <2.5.0-M1"
        },
        "solace-spring-cloud": {
            "1.0.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "1.1.1": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
            "2.0.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1"
        },
        "spring-cloud": {
            "Hoxton.SR11": "Spring Boot >=2.2.0.RELEASE and <2.3.999.BUILD-SNAPSHOT",
            "Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.3.999.BUILD-SNAPSHOT and <2.4.0.M1",
            "2020.0.0-M3": "Spring Boot >=2.4.0.M1 and <=2.4.0.M1",
            "2020.0.0-M4": "Spring Boot >=2.4.0.M2 and <=2.4.0-M3",
            "2020.0.0": "Spring Boot >=2.4.0.M4 and <=2.4.0",
            "2020.0.3": "Spring Boot >=2.4.1 and <2.5.2-SNAPSHOT",
            "2020.0.4-SNAPSHOT": "Spring Boot >=2.5.2-SNAPSHOT"
        },
        "spring-cloud-alibaba": {
            "2.2.1.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1"
        },
        "spring-cloud-gcp": {
            "2.0.0": "Spring Boot >=2.4.0-M1 and <2.5.0-M1"
        },
        "spring-cloud-services": {
            "2.2.6.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.RELEASE",
            "2.3.0.RELEASE": "Spring Boot >=2.3.0.RELEASE and <2.4.0-M1",
            "2.4.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1"
        },
        "spring-geode": {
            "1.2.12.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "1.3.11.RELEASE": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
            "1.4.6": "Spring Boot >=2.4.0-M1 and <2.5.0-M1",
            "1.5.0": "Spring Boot >=2.5.0-M1"
        },
        "vaadin": {
            "14.6.3": "Spring Boot >=2.1.0.RELEASE and <2.6.0-M1"
        },
        "wavefront": {
            "2.0.2": "Spring Boot >=2.1.0.RELEASE and <2.4.0-M1",
            "2.1.1": "Spring Boot >=2.4.0-M1 and <2.5.0-M1",
            "2.2.0": "Spring Boot >=2.5.0-M1"
        }
    },
    "dependency-ranges": {
        "native": {
            "0.9.0": "Spring Boot >=2.4.3 and <2.4.4",
            "0.9.1": "Spring Boot >=2.4.4 and <2.4.5",
            "0.9.2": "Spring Boot >=2.4.5 and <2.5.0-M1",
            "0.10.0": "Spring Boot >=2.5.0-M1 and <2.5.2-M1",
            "0.10.1-SNAPSHOT": "Spring Boot >=2.5.2-M1 and <2.6.0-M1"
        },
        "okta": {
            "1.4.0": "Spring Boot >=2.2.0.RELEASE and <2.4.0-M1",
            "1.5.1": "Spring Boot >=2.4.0-M1 and <2.4.1",
            "2.0.1": "Spring Boot >=2.4.1 and <2.5.0-M1"
        },
        "mybatis": {
            "2.1.4": "Spring Boot >=2.1.0.RELEASE and <2.5.0-M1",
            "2.2.0": "Spring Boot >=2.5.0-M1"
        },
        "camel": {
            "3.3.0": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "3.5.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
            "3.10.0": "Spring Boot >=2.4.0.M1 and <2.5.0-M1"
        },
        "open-service-broker": {
            "3.1.1.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1",
            "3.2.0": "Spring Boot >=2.3.0.M1 and <2.4.0-M1",
            "3.3.0": "Spring Boot >=2.4.0-M1 and <2.5.0-M1"
        }
    }
}

其中重点关注如下依赖

  • spring-cloud
  • spring-cloud-alibaba
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值