目录
一、认识与安装
他是阿里巴巴的产品,也是SpringCloud中的一个注册中心组件,其功能相比Eureka更丰富,在国内更受欢迎。下面来安装它:
1、访问
Release 1.4.5 (Mar 17th, 2023) · alibaba/nacos · GitHuban easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications. - Release 1.4.5 (Mar 17th, 2023) · alibaba/nacoshttps://github.com/alibaba/nacos/releases/tag/1.4.5
2、下载
推荐1.4.x版本
上面是Linux版本,下面是Windows版本
3、解压
要解压到非中文目录下
4、启动
找到解压的目录点击bin进入后点击startup.cmd或者在bin目录下打开cmd输入以下指令即可启动
5、访问
启动后访问提示的url即可,登录时
二、基本使用
1、搭建服务
我们需要在项目的父工程里引入以下依赖
<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>
2、服务注册
在进行服务注册时,我们先要引入一下依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
然后在配置文件中进行配置
3、服务发现
与之前Eureka服务发现时相同