下载
官网地址:https://github.com/alibaba/nacos/releases
解压
tar -zxvf nacos
启动Nacos
目录到nacos的bin目录下
cd nacos/bin/
后端启动命令
sh startup.sh -m standalone
备注:
1.nacos端口时8848,要访问时记得开通端口防火墙
2.目前使用1.4.1稳定版;如果使用高版本启动会报错会提示classNotFound
启动成功后打开http://localhost:8848/nacos/index.html 输入账号密码即可进入
项目引用
pom.xml依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
备注:添加spring-boot-starter-web,不能是spring-web 不然启动容易报错或者注册不成功
yml配置文件
spring:
cloud:
nacos:
discovery:
server-addr: 192.168.1.117:8848