Spring Cloud 快速入门-详细基础知识

Spring Cloud 入门

1、概述

1.1、什么是 Spring Cloud

Spring Cloud 是一系列框架的有序集合。它利用 Spring Boot 的开发便利性巧妙地简化了分布式系统基础设施的开发,如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等,都可以用 Spring Boot 的开发风格做到一键启动和部署。 Spring Cloud 并没有重复制造轮子,它只是将各家公司开发的比较成熟、经得起实际考验的服务框架组合起来,通过 Spring Boot 风格进行再封装屏蔽掉了复杂的配置和实现原理,最终给开发者留出了一套简单易懂、易部署和易维护的分布式系统开发工具包。

解决方案:

  • Spring Cloud NetFlix 一站式解决方案
    • API 网关,zuul 组件
    • Feign 基于 HttpClinet 同步阻塞, 通信
    • Eureka 服务注册发现
    • Hystrix 熔断机制
  • Apache Dubbo Zookeeper 半自动
    • Dubbo 通信框架
    • Zookeeper 服务注册发现
  • Spring Cloud Alibaba 一站式解决方案,配置比 NetFlix 更简单易用

服务网格: Server Mesh

  • istio

结构:

  • API 网关,路由
  • 通信
  • 服务注册发现
  • 熔断机制

1.2、Spring CloudSpring Boot 的关系

  • Spring Boot 专注于快速方便的开发单个个体的微服务
  • Spring Cloud 是关注全局的微服务协调整理治理框架,它将 Spring Boot 开发的一个个单体微服务整合并管理起来,为各个微服务之前提供:配置管理,服务发现,断路器,路由,微代理,事件总线,全局锁,决策竞选,分布式会话登集成服务。
  • Spring Boot 可以离开 Spring Cloud 独立使用,开发项目,但 Spring Cloud 离不开 Spring Boot ,属于依赖关系。
  • Spring Boot 专注于快速、方便的开发单个个体微服务, Spring cloud 关注全局的服务治理框架

1.3、DubboSpring Cloud 技术选型

1.3.1、分布式+服务治理 Dubbo

目前成熟的互联网架构:应用服务化拆分+消息中间件

1.3.2、DubboSpring Cloud 对比
Dubbo Spring
服务注册中心 Zookeeper Spring Cloud Netflix Eureka
服务调用方式 RPC REST API
服务监控 Dubbo-monitor Spring Boot Admin
断路器 不完善 Spring Cloud Netflix Hystrix
服务网关 Spring Cloud Netflix Zuul
分布式配置 Spring Cloud Config
服务跟踪 Spring Cloud Sleuth
消息总线 Spring Cloud Bus
数据流 Spring Cloud Stream
批量任务 Spring Cloud Task

最大区别: Spring Cloud 抛弃了 DubboRPC 通信,采用基于 HTTPREST 方式

严格来说,这两种方式各有优劣。虽然从一定程度上来说,后者牺牲了服务调用的性能,但是也避免了上面提到的原生 RPC 带来的问题。而且 REST 相比 RPC 更加的灵活,服务提供方和调用方的依赖只依靠一纸契约,不存在代码级别的强依赖,这在强调快速演化的的微服务环境下,显得更加的合适。

Dubbo 定位是一款 RPC 框架, Spring Cloud 目标是微服务架构下的一站式解决方案。

1.4、Spring Cloud 可以做到那些

  • 分布式,版本控制配置
  • 服务注册与发现
  • 路由
  • 服务到服务的调用
  • 负载均衡配置
  • 断路器
  • 分布式消息管理

1.5、版本

Spring Cloud 是一个有众多子项目组成的一个大型综合项目,每个子项目有不同的发行节奏,都维护着自己的发布版本号。 Spring Cloud 通过一个资源清单 BOM (Bill of Materials) 来管理每个版本的子项目清单。为避免与子项目的发布号混淆,所以没有采用版本号的方式,而是通过命名的方式。

在这里插入图片描述

2、入门使用

2.1、技术选型

{
   
    "git": {
   
        "branch": "58cb6bccc1be3cdbe108a4609797c53010545926",
        "commit": {
   
            "id": "58cb6bc",
            "time": "2020-08-21T06:52:21Z"
        }
    },
    "build": {
   
        "version": "0.0.1-SNAPSHOT",
        "artifact": "start-site",
        "versions": {
   
            "spring-boot": "2.3.3.RELEASE",
            "initializr": "0.9.2-SNAPSHOT"
        },
        "name": "start.spring.io website",
        "time": "2020-08-21T07:23:55.515Z",
        "group": "io.spring.start"
    },
    "bom-ranges": {
   
        "azure": {
   
            "2.0.10": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE",
            "2.1.10": "Spring Boot >=2.1.0.RELEASE and <2.2.0.M1",
            "2.2.4": "Spring Boot >=2.2.0.M1 and <2.3.0.M1",
            "2.3.1": "Spring Boot >=2.3.0.M1"
        },
        "codecentric-spring-boot-admin": {
   
            "2.0.6": "Spring Boot >=2.0.0.M1 and <2.1.0.M1",
            "2.1.6": "Spring Boot >=2.1.0.M1 and <2.2.0.M1",
            "2.2.4": "Spring Boot >=2.2.0.M1 and <2.3.0.M1",
            "2.3.0": "Spring Boot >=2.3.0.M1 and <2.4.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"
        },
        "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"
        },
        "spring-cloud": {
   
            "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.SR6": "Spring Boot >=2.1.0.RELEASE and <2.1.17.BUILD-SNAPSHOT",
            "Greenwich.BUILD-SNAPSHOT": "Spring Boot >=2.1.17.BUILD-SNAPSHOT and <2.2.0.M4",
            "Hoxton.SR7": "Spring Boot >=2.2.0.M4 and <2.3.4.BUILD-SNAPSHOT",
            "Hoxton.BUILD-SNAPSHOT": "Spring Boot >=2.3.4.BUILD-SNAPSHOT and <2.4.0.M1",
            "2020.0.0-SNAPSHOT": "Spring Boot >=2.4.0.M1"
        },
        "spring-cloud-alibaba": {
   
            "2.2.1.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1"
        },
        "spring-cloud-services": {
   
            "2.0.3.RELEASE": "Spring Boot >=2.0.0.RELEASE and <2.1.0.RELEASE",
            "2.1.7.RELEASE": "Spring Boot >=2.1.0.RELEASE and <2.2.0.RELEASE",
            "2.2.3.RELEASE": "Spring Boot >=2.2.0.RELEASE and <2.3.0.M1"
        },
        "spring-statemachine": {
   
            "2.0.0.M4": "Spring Boot >=2.0.0.RC1 and <=2.0.0.RC1",
            "2.0.0.M5": "Spring Boot >=2.0.0.RC2 and <=2.0.0.RC2",
            "2.0.1.RELEASE": "Spring Boot >=2.0.0.RELEASE"
        },
        "vaadin": {
   
            "10.0.17": "Spring Boot >=2.0.0.M1 and <2.1.0.M1"
  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陌尘吖

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值