1、建立分组

2、建立配置

2.1配置详情

3、添加依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
4、添加注解
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
5、建立bootstrap.yml文件
spring:
application:
name: smart-work
cloud:
nacos:
config: #配置文件地址
server-addr: 127.0.0.1:8848
file-extension: yaml #文件类型
group: WORK_GROUP #分组
namespace: 817b2baa-868f-4fef-b3f7-d64e6
discovery: #服务注册空间
namespace: 817b2baa-868f-4fef-b3f7-d64e6
6、实现动态刷新 @RefreshScope
测试

修改前

修改后

|