Spring Cloud Alibaba-全面详解(学习总结---从入门到深化)

简介: Spring Cloud Alibaba致力于提供微服务开发的一站式解决方案。

2345_image_file_copy_549.jpg

Spring Cloud Alibaba简介

2345_image_file_copy_550.jpg

什么是Spring Cloud Alibaba

Spring Cloud Alibaba致力于提供微服务开发的一站式解决方案。 此项目包含开发分布式应用微服务的必需组件,方便开发者通过 Spring Cloud 编程模型轻松使用这些组件来开发分布式应用服务。

2345_image_file_copy_551.jpg

为什么要推出SpringCloud Alibaba呢?

2345_image_file_copy_552.jpg

问题: 但近几年来呢,许多的微服务组件已经闭源或者已经停止维护了 。

SpringCloudAlibaba 微服务组件内容与功能对比

Spring Cloud Alibaba是阿里巴巴结合自身的微服务实践开源的微服务全家桶。

2345_image_file_copy_553.jpg SpringCloud 和 Spring Cloud Alibaba的功能对比

2345_image_file_copy_554.jpg2345_image_file_copy_555.jpg

更换组件后微服务架构图

2345_image_file_copy_556.jpg

1.Spring Cloud Alibaba提供_____解决方案。微服务开发的一站式

2. 为什么要推出SpringCloud Alibaba____。已经闭源或者已经停止维护

Spring Cloud Alibaba版本与兼容性

image.jpeg

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

Spring Cloud维护主线版本

2345_image_file_copy_558.jpg

2345_image_file_copy_559.jpg

2345_image_file_copy_560.jpg

2345_image_file_copy_561.jpg

组件版本关系

下表为按时间顺序发布的 Spring Cloud Alibaba 以及对应的适配 Spring Cloud 和 Spring Boot 版本关系(由于 Spring Cloud 版本 命名有调整,所以对应的 Spring Cloud Alibaba 版本号也做了对应变化)  

2345_image_file_copy_562.jpg

SpringCloud与SpringBoot版本选型

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

下表为按时间顺序发布的 Spring Cloud Alibaba 以及对应的适配 Spring Cloud 和 Spring Boot 版本关系(由于 Spring Cloud 版本 命名有调整,所以对应的 Spring Cloud Alibaba 版本号也做了对应 变化)

2345_image_file_copy_563.jpg 1.通过查看____信息可以发现某个版本是Spring Cloud维护主线版本。GA

2.Spring Cloud Hoxton.SR9版本对应SpringCloud Alibaba的版 本是__。2.2.6.RELEASE

分布式服务治理_什么是Nacos

2345_image_file_copy_564.jpg

Nacos是阿里巴巴开源的服务注册中心以及配置中心,致力于给开 发者提供一款便捷、简单上手的开源框架。

2345_image_file_copy_565.jpg

image.jpeg

为什么Nacos这么受欢迎

Nacos官方文档的介绍中有这么一句话,如下:

Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范 式、云原生范式) 的服务基础设施。

2345_image_file_copy_567.jpg

Eureka 、 Config 这两个组件相信大家都用过,有什么感受?

2345_image_file_copy_568.jpg

2345_image_file_copy_569.jpg

Nacos主要提供以下四大功能

1、服务发现和服务健康测

Nacos 使服务更容易注册,并通过DNS或HTTP接口发现其他服务, Nacos还提供服务的实时健康检查,以防止向不健康的主机或服务实例发送请求。

2、动态配置服务

动态配置服务允许您在所有环境中以集中和动态的方式管理所有服 务的配置。Nacos消除了在更新配置时重 新部署应用程序, 这使配置的更改更加高效和灵活。

3、动态 DNS 服务

Nacos提供基于DNS协议的服务发现能力,旨在支持异构语言的服 务发现,支持将注册在Nacos上的服务以域名的方式暴露端点,让三方应用方便查阅及发现。

4、服务及其元数据管理

Nacos能让您从微服务平台建设的视觉管理数据中心的所有服务及 元数据,包括管理服务的描述、生命周期、服务的静态依赖分析、 服务的健康状态、服务的流量管理、路由及安全策略。

Nacos名字由来

2345_image_file_copy_570.jpg

2345_image_file_copy_571.jpg

1.Spring Cloud Alibaba中Nacos组件是___。服务注册中心以及配置中心

2. Spring Cloud Alibaba中Nacos组件干掉了Spring Cloud哪三 个组件,分别是____。

Eureka、Bus、Config

分布式服务治理_Nacos Server下载安装

2345_image_file_copy_572.jpg

官网下载

Releases · alibaba/nacos · GitHub

2345_image_file_copy_573.jpg 下载后解压

tar -zxvf nacos-server-1.4.3.tar.gz -C /usr/local

启动服务器

sh startup.sh -m standalone

注意: standalone代表着单机模式运行

测试

请求http://192.168.66.100:8848/nacos

2345_image_file_copy_574.jpg

分布式服务治理_Docker安装Nacos Server服务

2345_image_file_copy_575.jpg

下载镜像

docker pull nacos/nacos-server:1.4.3

单机版部署

docker run --name nacos -d -p 8848:8848 -e
MODE=standalone -e
NACOS_SERVER_IP=192.168.66.100 nacos/nacosserver

2345_image_file_copy_576.jpg

测试

请求http://192.168.66.100:8848/nacos

2345_image_file_copy_577.jpg

分布式服务治理_微服务聚合父工程构建

2345_image_file_copy_578.jpg

New Project

2345_image_file_copy_579.jpg

聚合总工程名称

2345_image_file_copy_580.jpg 字符编码

2345_image_file_copy_581.jpg

注解生效激活

2345_image_file_copy_582.jpg

Java编译版本选择

2345_image_file_copy_583.jpg

File Type过滤

2345_image_file_copy_584.jpg

父工程POM

<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xsi:schemaLocation="http://maven.apache.org/
POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <groupId>com.xiaotong</groupId>
   <artifactId>cloud</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>pom</packaging>
   <!-- 统一管理jar包版本 -->
   <properties>
       <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
       <maven.compiler.source>1.8</maven.compiler.source>
       <maven.compiler.target>1.8</maven.compiler.target>
       <spring-cloud.version>2021.0.0</spring-cloud.version>
       <spring-boot.version>2.6.3</spring-boot.version>
   </properties>
   <!-- 子模块继承之后,提供作用:锁定版本+子 modlue不用写groupId和version -->
   <dependencyManagement>
       <dependencies>
           <!--spring boot 2.6.3-->
           <dependency>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-bootstarter-parent</artifactId>
               <version>${springboot.version}</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
           <!--spring cloud 2021.0.0-->
           <dependency>
               <groupId>org.springframework.cloud</groupId>
               <artifactId>spring-clouddependencies</artifactId>
               <version>${springcloud.version}</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
       </dependencies>
   </dependencyManagement>
</project>

IDEA开启Dashboard

普通的Run面板

2345_image_file_copy_585.jpg

Run Dashboard面板

2345_image_file_copy_586.jpg

修改配置文件

在.idea/workspace.xml 文件中找到

添加配置

<component name="RunDashboard">
  <option name="ruleStates">
    <list>
      <RuleState>
        <option name="name" value="ConfigurationTypeDashboardGroupingRule" />
      </RuleState>
      <RuleState>
        <option name="name" value="StatusDashboardGroupingRule" />
      </RuleState>
    </list>
  </option>
  <option name="configurationTypes">
  <set>
    <option value="SpringBootApplicationConfigurationType" />
  </set>
</option>
</component>
目录
相关文章
|
26天前
|
资源调度 Java 调度
Spring Cloud Alibaba 集成分布式定时任务调度功能
定时任务在企业应用中至关重要,常用于异步数据处理、自动化运维等场景。在单体应用中,利用Java的`java.util.Timer`或Spring的`@Scheduled`即可轻松实现。然而,进入微服务架构后,任务可能因多节点并发执行而重复。Spring Cloud Alibaba为此发布了Scheduling模块,提供轻量级、高可用的分布式定时任务解决方案,支持防重复执行、分片运行等功能,并可通过`spring-cloud-starter-alibaba-schedulerx`快速集成。用户可选择基于阿里云SchedulerX托管服务或采用本地开源方案(如ShedLock)
|
1月前
|
XML Java 测试技术
Spring5入门到实战------17、Spring5新功能 --Nullable注解和函数式注册对象。整合JUnit5单元测试框架
这篇文章介绍了Spring5框架的三个新特性:支持@Nullable注解以明确方法返回、参数和属性值可以为空;引入函数式风格的GenericApplicationContext进行对象注册和管理;以及如何整合JUnit5进行单元测试,同时讨论了JUnit4与JUnit5的整合方法,并提出了关于配置文件加载的疑问。
Spring5入门到实战------17、Spring5新功能 --Nullable注解和函数式注册对象。整合JUnit5单元测试框架
|
18天前
|
小程序 前端开发 Java
SpringBoot+uniapp+uview打造H5+小程序+APP入门学习的聊天小项目
JavaDog Chat v1.0.0 是一款基于 SpringBoot、MybatisPlus 和 uniapp 的简易聊天软件,兼容 H5、小程序和 APP,提供丰富的注释和简洁代码,适合初学者。主要功能包括登录注册、消息发送、好友管理及群组交流。
41 0
SpringBoot+uniapp+uview打造H5+小程序+APP入门学习的聊天小项目
|
20天前
|
人工智能 前端开发 Java
【实操】Spring Cloud Alibaba AI,阿里AI这不得玩一下(含前后端源码)
本文介绍了如何使用 **Spring Cloud Alibaba AI** 构建基于 Spring Boot 和 uni-app 的聊天机器人应用。主要内容包括:Spring Cloud Alibaba AI 的概念与功能,使用前的准备工作(如 JDK 17+、Spring Boot 3.0+ 及通义 API-KEY),详细实操步骤(涵盖前后端开发工具、组件选择、功能分析及关键代码示例)。最终展示了如何成功实现具备基本聊天功能的 AI 应用,帮助读者快速搭建智能聊天系统并探索更多高级功能。
152 2
【实操】Spring Cloud Alibaba AI,阿里AI这不得玩一下(含前后端源码)
|
27天前
|
缓存 前端开发 JavaScript
前后端分离 SpringBoot+Vue商城买卖系统通杀版本。大家可以参考学习一下
这篇文章介绍了一个使用SpringBoot+Vue开发的前后端分离商城系统,包括技术架构、开发环境、实现的功能以及项目截图,并展示了普通用户和商家端的功能界面。
前后端分离 SpringBoot+Vue商城买卖系统通杀版本。大家可以参考学习一下
|
27天前
|
Java 数据库连接 Spring
后端框架入门超详细 三部曲 Spring 、SpringMVC、Mybatis、SSM框架整合案例 【爆肝整理五万字】
文章是关于Spring、SpringMVC、Mybatis三个后端框架的超详细入门教程,包括基础知识讲解、代码案例及SSM框架整合的实战应用,旨在帮助读者全面理解并掌握这些框架的使用。
后端框架入门超详细 三部曲 Spring 、SpringMVC、Mybatis、SSM框架整合案例 【爆肝整理五万字】
|
29天前
|
NoSQL Java Redis
Redis6入门到实战------ 八、Redis与Spring Boot整合
这篇文章详细介绍了如何在Spring Boot项目中整合Redis,包括在`pom.xml`中添加依赖、配置`application.properties`文件、创建配置类以及编写测试类来验证Redis的连接和基本操作。
Redis6入门到实战------ 八、Redis与Spring Boot整合
|
29天前
|
Java 微服务 Spring
SpringBoot+Vue+Spring Cloud Alibaba 实现大型电商系统【分布式微服务实现】
文章介绍了如何利用Spring Cloud Alibaba快速构建大型电商系统的分布式微服务,包括服务限流降级等主要功能的实现,并通过注解和配置简化了Spring Cloud应用的接入和搭建过程。
SpringBoot+Vue+Spring Cloud Alibaba 实现大型电商系统【分布式微服务实现】
|
1月前
|
XML Java Maven
Spring5入门到实战------16、Spring5新功能 --整合日志框架(Log4j2)
这篇文章是Spring5框架的入门到实战教程,介绍了Spring5的新功能——整合日志框架Log4j2,包括Spring5对日志框架的通用封装、如何在项目中引入Log4j2、编写Log4j2的XML配置文件,并通过测试类展示了如何使用Log4j2进行日志记录。
Spring5入门到实战------16、Spring5新功能 --整合日志框架(Log4j2)
|
17天前
|
缓存 Java Spring
Spring缓存实践指南:从入门到精通的全方位攻略!
【8月更文挑战第31天】在现代Web应用开发中,性能优化至关重要。Spring框架提供的缓存机制可以帮助开发者轻松实现数据缓存,提升应用响应速度并减少服务器负载。通过简单的配置和注解,如`@Cacheable`、`@CachePut`和`@CacheEvict`,可以将缓存功能无缝集成到Spring应用中。例如,在配置文件中启用缓存支持并通过`@Cacheable`注解标记方法即可实现缓存。此外,合理设计缓存策略也很重要,需考虑数据变动频率及缓存大小等因素。总之,Spring缓存机制为提升应用性能提供了一种简便快捷的方式。
25 0