1 @NacosValue 自动刷新
环境依赖版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<version>0.2.7</version>
</dependency>
@NacosPropertySource(dataId = "mydata", autoRefreshed = true) 同时 @NacosValue(value = "${my_ky}",autoRefreshed = true) 同时设置autoRefreshed = true 才能接受到nacos的push数据。
2 @Value 自动刷新
环境依赖版本 SpringCloud 是个大前提,不然还是考虑上面方式或者原生接入方案;
@NacosPropertySource(dataId = "mydata", autoRefreshed = true) 同

博客围绕@NacosValue和@Value自动刷新展开。指出环境依赖版本SpringCloud是大前提,使用@NacosPropertySource和@RefreshScope可接收nacos的push数据。还提到两种实现方式都有不足,如@NacosValue对SPEL表达式支持不友好。
最低0.47元/天 解锁文章
1949





