Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot Spring云配置刷新配置_Spring Boot_Spring Cloud Config - Fatal编程技术网

Spring boot Spring云配置刷新配置

Spring boot Spring云配置刷新配置,spring-boot,spring-cloud-config,Spring Boot,Spring Cloud Config,是否可以通过调用java方法来刷新配置以使用REST api: curl localhost:8080/exactor/refresh-d{}-H“内容类型:application/json”您可以使用fromspring云上下文: @Autowired private RestartEndpoint restartEndpoint; ... Thread restartThread = new Thread(() -> restartEndpoint.restart()); rest

是否可以通过调用java方法来刷新配置以使用REST api:

curl localhost:8080/exactor/refresh-d{}-H“内容类型:application/json”
您可以使用from
spring云上下文:

@Autowired
private RestartEndpoint restartEndpoint;

...

Thread restartThread = new Thread(() -> restartEndpoint.restart());
restartThread.setDaemon(false);
restartThread.start();

这就是如何做到这一点。但是请注意,SpringCloud文档还说,只要它们是RefreshScope,您就可以使用它们。

谢谢。只是一个问题,为什么在线程中使用restartEndpoint?异步调用它()是有意义的,但我不确定您是否需要再这样做,因为它似乎已添加到v2中的底层代码中-