Spring Cloud Alibaba环境搭建
前言:Spring Cloud Alibaba是目前主流的分布式微服务架构,本文主要讲解了在IDEA中如何搭建Spring Cloud Alibaba环境,以及介绍Spring Cloud Alibaba各个版本之间的关系和搭建Spring Cloud前的准备工作。
前置准备
Spring Cloud Alibaba需要依赖 Java 环境运行,同时还需要配置 Maven 环境,确保是以下版本:
版本说明
查看官网的版本说明
组件版本关系
下图中版本关系无需自己设置,在Spring Cloud Alibaba 版本管理器spring-cloud-alibaba-dependencies
已经配置,引入该依赖即可
毕业版本依赖关系(推荐使用)
不同的Spring Cloud Alibaba版本之间的版本依赖关系不同,创建时需要自己查看官网说明,选择RELEASE版本(发行版)
搭建方法
pom.xml
<properties>
<spring.cloud.alibaba.version>2.2.6.RELEASE</spring.cloud.alibaba.version>
<spring.boot.version>2.3.2.RELEASE</spring.boot.version>
<spring.cloud.version>Hoxton.SR9</spring.cloud-version>
</properties>
<dependencyManagement>
<dependencies>
<!--Spring Cloud Alibaba 版本管理器-->
<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>
<!--Spring Boot 版本管理器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--Spring Cloud 版本管理器-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Spring Boot 版本管理器里面的spring-boot-dependencies
和spring-boot-starter-parent
是一样,两种名字都可以
Spring脚手架创建
构建项目:约定 > 配置 > 编码
父工程
- 在IDEA中新建父工程(父工程用于约定整个SpringCloud项目的版本)
- 选择 Spring Initializr
- 填写项目信息,注意:选择Maven POM和Java版本(JDK)
选择Maven POM创建项目不会创建src
文件,只有pom.xml
文件,父工程足够使用
- 选择Spring Boot版本(随便选择,后面需要修改)
- 检查项目名称和保存位置,点击Finish。等待创建完成,出现界面则创建完成
- 完成创建后,打开
pom.xml
文件添加如下内容,添加SpringCloudAlibaba、SpringBoot和SpringCloud的依赖
pom.xml
<properties>
<spring.cloud.alibaba.version>2.2.6.RELEASE</spring.cloud.alibaba.version>
<spring.boot.version>2.3.2.RELEASE</spring.boot.version>
<spring.cloud.version>Hoxton.SR9</spring.cloud-version>
</properties>
<dependencyManagement>
<dependencies>
<!--Spring Cloud Alibaba 版本管理器-->
<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>
<!--Spring Boot 版本管理器-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--Spring Cloud 版本管理器-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring.cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Spring Boot 版本管理器里面的spring-boot-dependencies
和spring-boot-starter-parent
是一样,两种名字都可以
- 父工程搭建完成,其他如服务发现注册、配置中心、消息总线、负载均衡、断路器、数据监控等组件需要时在父工程的
pom.xml
中引入相关依赖即可,这里先略过
子模块
- 在父工程中新建模块
- 选择Maven,点击Next。
- 填写子模块名(服务名)
相比于Spring官方提供的脚手架,使用阿里云脚手架来创建会更加快捷方便,阿里云重点面向微服务项目
IDEA设置
添加SpringBoot的服务选项卡
快速管理各个服务的状态
- 编辑配置
- 添加SpringBoot服务
- 找到 SpringBoot
- 点击OK后,下方就会出现一个Services,用于查看Spring Boot的微服务状态
服务改名
- 右键点击服务,选择下图的红框打开
- 修改配置信息
Spring Cloud Alibaba环境搭建的更多相关文章
- Spring Cloud Alibaba+Nacos搭建微服务架构
1. Spring Cloud Alibaba 简介 Spring Cloud Alibaba是阿里巴巴为分布式应用提供的一站式解决方案,能够更方便快捷地搭建分布式平台,nacos拥有着替换eu ...
- Docker composer搭建Spring Cloud Alibaba 运行环境(二)
" Spring Cloud Alibaba要用到的组件很多,注册中心nacos, 限流sentinel, 数据库,网关等等.由于用到的组件相对较多,部署会很繁琐,最关键的是没有资源服务器, ...
- Spring Cloud Alibaba(7)---docker-compose搭建nacos1.4.0集群
docker-compose搭建nacos1.4.0集群 有关Nacos之前写过四篇文章. Spring Cloud Alibaba(3)---Nacos概述 Spring Cloud Alibaba ...
- Spring Cloud Alibaba(10)---Sentinel控制台搭建+整合SpringCloudAlibaba
上一篇博客讲了Sentinel一些概念性的东西 Spring Cloud Alibaba(9)---Sentinel概述 这篇博客主要讲 Sentinel控制台搭建,和 整合SpringCloudAl ...
- Spring Cloud Alibaba基础教程:Nacos的集群部署
继续说说生产环境的Nacos搭建,通过上一篇<Spring Cloud Alibaba基础教程:Nacos的数据持久化>的介绍,我们已经知道Nacos对配置信息的存储原理,在集群搭建的时候 ...
- Spring Cloud Alibaba到底坑不坑?
之前我发过一篇<说说我为什么看好Spring Cloud Alibaba>,然后这两天有网友给我转了这篇文章<坑爹项目spring-cloud-alibaba,我们也来一个>, ...
- Spring Cloud Alibaba基础教程:Nacos的数据持久化
前情回顾: <Spring Cloud Alibaba基础教程:使用Nacos实现服务注册与发现> <Spring Cloud Alibaba基础教程:支持的几种服务消费方式> ...
- Spring Cloud Alibaba | 序言
目录 Spring Cloud Alibaba | 序言 1. Spring Cloud Alibaba是什么? 2. 主要功能 3. 组件 4. 版本说明 4.1 版本依赖关系 4.2 组件版本关系 ...
- spring cloud alibaba 简介
### Spring Cloud Alibaba [官方github地址](https://github.com/alibaba/spring-cloud-alibaba) Spring Cloud ...
随机推荐
- PHP中的日期相关函数(一)
日期相关的操作函数是我们在日常的工作开发中最常接触到的功能.当然,大部分同学可能最多用到的就是 date() . time() 这两个函数,我们今天先不讲这两个函数,或许后面的文章也不太会讲它们,毕竟 ...
- PHPDebug互动扩展【phpdbg】功能浅析
对于 PHP 开发者来说,单步的断点 Debug 调试并不是我们的必修课,而 Java . C# . C++ 这些静态语言则会经常性地进行这种调试.其实,我们 PHP 也是支持这类调试方式的,特别是对 ...
- js屏蔽右键代码
<script type="text/javascript"> document.body.oncontextmenu=document.body.ondragstar ...
- JavaScript对象的两类属性(数据属性与访问器属性)
对JavaScript来说,属性并非只是简单的名称和值,JavaScript用一组特征(attribute)来描述属性 (property). 第一类属性数据属性具有四个特征. value:就是属性的 ...
- Dapr + .NET Core实战(五)Actor
什么是Actor模式 Actors 为最低级别的"计算单元" 以上解释来自官方文档,看起来"晦涩难懂".大白话就是说Actors模式是一段需要单线程执行的代码块 ...
- Modern PHP interface 接口
The right way /dev/hell Code Response.php 接口 demo: modern-php/├── data│ └── stream.txt└── interfac ...
- JavaScript 获取html元素
1.通过ID获取: document.getElementById("idname"); 2.通过class.tagname获取: var wcyclass = document. ...
- Jmeter压测学习4--XPath提取器
没有遇到,直接转载:https://www.cnblogs.com/yoyoketang/p/11962553.html 前言 有些web项目是前后端不分离的,返回的内容不是那种纯进口返回json格式 ...
- Vite插件开发纪实:vite-plugin-monitor(上)
背景 最近在webpack项目里接入了Vite(dev mode),为开发提效.效果是真的猛. 项目启动速度提升70%-80%,HMR直接碾压webpack dev server 为了更加精准的计算收 ...
- Python 通过 .cube LUT 文件对图像加滤镜
Python 通过 .cube LUT 文件对图像加滤镜 一个好用的python给图片加滤镜的代码: https://github.com/CKboss/PyApplyLUT 这个是对C++代码的封装 ...