参考官方文档: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;
}
}版权声明:本文为weixin_47384874原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。