nacos 配置动态刷新_Nacos 动态刷新@RefreshScope 【实现配置和实例刷新】
1、在需要?jiǎng)討B(tài)刷新的類上加上@RefreshScope對(duì)Bean實(shí)例動(dòng)態(tài)刷新
package com.ne.isuzu.sim.manage.web.controller;
/**
*
* 動(dòng)態(tài)刷新測(cè)試
*
*
* @author Yungui.Zheng
* @since 2020-07-02
*/
@Api(description = "流程操作")
@RestController
@RequestMapping("/sim/order/process")
@Slf4j
@RequiredArgsConstructor
@Validated
@RefreshScope
public class SimOrderProcessController {
private final ISimOrderProcessService processService;
/**
* 動(dòng)態(tài)數(shù)值
*/
@Value("${andy.age}")
private Integer age;
@ApiOperation(value = "動(dòng)態(tài)刷新測(cè)試")
@GetMapping(value = "/test")
public Response> test() {
return Response.success(age);
}
}
動(dòng)態(tài)刷新
Nacos Config Starter 默認(rèn)為所有獲取數(shù)據(jù)成功的 Nacos 的配置項(xiàng)添加了監(jiān)聽功能,在監(jiān)聽到服務(wù)端配置發(fā)生變化時(shí)會(huì)實(shí)時(shí)觸發(fā) org.springframework.cloud.context.refresh.ContextRefresher 的 refresh 方法 。
如果需要對(duì) Bean 進(jìn)行動(dòng)態(tài)刷新,請(qǐng)參照 Spring 和 Spring Cloud 規(guī)范。推薦給類添加 @RefreshScope 或 @ConfigurationProperties 注解
總結(jié)
以上是生活随笔為你收集整理的nacos 配置动态刷新_Nacos 动态刷新@RefreshScope 【实现配置和实例刷新】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: rust挖油机怎么整_挖掘机发动机进气管
- 下一篇: 0xbc指令 st75256_DDOS终