Springcloud-alibaba 笔记

190 阅读3分钟

Springcloud-alibaba微服务工具集

demo地址

gitee.com/w--kk/sprin…

  1. springcloud
    spring团队开源微服务工具集帮助我们快速构建分布式系统(微服务系统)  提供spring组织 netflix开源解决方案
  2. springcloud alibaba
    alibaba团队开源微服务工具集助我们快速构建分布式系统 (微服务系统)  提供alibaba解决方案
  3. springcloud alibaba
    最新版本: 2.2.1 RELEASE
    官方定义:
    Spring cloud Alibaba provides one-stop solution (解决放哪) for distributed application development(分布式应用开发)
    spring cloud 阿里巴巴为分布式应用开发了提供一站式解决方案
  4. 微服务项目实战开发 SpringCloud NetFlix + SpringCloud Spring + SpringCloud alibaba
    a. 服务注册中心 ===> Nacos
    b. 服务间通信负载均衡 ===> HttpRest (RestTemplate + Ribbon 、Openfeign)
    c. 服务流控和服务降级 ===> Sentinel
    d. 服务网关组件 ===> Gateway f. 统一配置中心组件 ===> Nacos

简介

Spring Cloud Alibaba provides a one-stop solution for distributed application development. It contains all the components required to develop distributed applications, making it easy for you to develop your applications using Spring Cloud.

  • spring cloud 用来解决微服务系统中(分布式系统)解决方案
  • spring cloud alibaba 用来解决微服务系统中解决方案

With Spring Cloud Alibaba, you only need to add some annotations and a small amount of configurations to connect Spring Cloud applications to the distributed solutions of Alibaba, and build a distributed application system with Alibaba middleware.

  1. 原文翻译
  • spring.io/projects/sp…
  • 阿里云为分布式应用开发提供了一站式解决方案。它包含了开发分布式应用程序所需的所有组件,使您可以轻松地使用springcloud开发应用程序。
  • 有了阿里云,你只需要添加一些注解和少量的配置,就可以将Spring云应用连接到阿里的分布式解决方案上,用阿里中间件搭建一个分布式应用系统。
  1. spring cloud alibaba 特点
  • a.服务降级和流量控制 sentinel 替换 hystrix
  • b.服务注册与发现 nacos 替换 eureka consul
  • c.分布式配置& 事件驱动消息总线 nacos 替换 config & bus
  • d.分布式事务&dubbo seta
  1. springcloud 组件
  • 服务注册与发现组件 eureka consul nacos
  • 服务间通信组件 restTemplate+ribbon,Openfeign restTemplate+ribbon,Openfeign
  • 服务降级和熔断 hystrix hystrix dashboard sentinel
  • 服务网关组件 gateway gateway
  • 统一配置中心组件 消息总线组件 config bus nacos\

springcloud alibaba 特性、特点、提供组件

  • Flow control and service degradation  服务流控制和 服务降级(熔断)====> Sentinel 替换springcloud原有Hystrix组件
  • Service registration and discovery  服务注册和发现组件 ====> Nacos 替换springcloud consul和eureka组件
  • Distributed Configuration  统一配置中心组件 ====> Nacos 替换springcloud config组件 自动配置刷新
  • Event-driven  事件驱动利用MQ RocketMQ ====> 事件驱动 替换Bus组件实现消息总线
  • Message Bus  消息总线 (异步处理)
  • Distributed Transaction 分布式事务 ====> Seata
  • Dubbo RPC 集成Dubbo实现服务间通信 ====> Dubbo RPC ====>替换原始项目中 RestTemplate openfeign(这两个都是http协议)

环境搭建

创建全局父项目
维护springcloud依赖    Hoxton.SR6
维护alibaba依赖     2.2.1.RELEASE
维承springboot父项目     2.2.5.RELEASE

  1. 构建项目并引入依赖
<!--定义springcloud版本-->
<properties>
  <spring.cloud.alibaba.version>2.2.1.RELEASE</spring.cloud.alibaba.version>
</properties>

<!--全局引入springcloudalibaba下载依赖地址,并不会引入依赖-->
<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.alibaba.cloud</groupId>
      <artifactId>spring-cloud-alibaba-dependencies</artifactId>
      <version>${spring.cloud.alibaba.version}</version>
      <type>pom</type>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

引用 编程不良人