1.准备nacos
2.开启nacos
开启命令:
cd /
D:
cd D:\gj\nacos2.4.3\nacos\nacos\bin
startup.cmd -m standalone
可以写成 .bat 文件直接运行指令
3.springboot 引入naocs依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
4.登录nacos ,启动springboot项目
springboot 版本
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.6.RELEASE</version> <relativePath/> </parent>
在项目与nacos之间会存在版本冲突!
5.在nacos中创建配置
在springboot 项目中增加bootstrap.properties文件
这里说明一下:
(1)编号5+编号4=demo.properties 对应的nacos demo.properties的配置文件
(2)编号2对应的是nacos中的配置id
(3)编号3对应哪个配置下的哪个分组
对应上才能找到咱们的配置文件启动成功后
端口8084
配置文件
配置成功