参考官方文档:https://github.com/alibaba/spring-cloud-alibaba/wiki/Nacos-config
@RefreshScope使用:
如果使用@Value获取配置文件中的信息 ,则需加上@RefreshScope可以动态的获取
@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {
@Value("${user}")
public String user;
@GetMapping("/add")
public String getConfig(){
return user;
}
}