spring-boot - Spring Cloud Config 刷新配置
问题描述
是否可以刷新调用 java 方法的配置而不是使用 REST api:
curl localhost:8080/actuator/refresh -d {} -H "Content-Type: application/json"
解决方案
您可以从以下位置使用ResartEndpoint 类spring-cloud-context
:
@Autowired
private RestartEndpoint restartEndpoint;
...
Thread restartThread = new Thread(() -> restartEndpoint.restart());
restartThread.setDaemon(false);
restartThread.start();
这就是@alexbt 建议的方式。但请注意,spring cloud 文档还说您可以刷新单个 bean,只要它们是 RefreshScope。
推荐阅读
- solr - Solr 搜索:与搜索查询匹配的多值字段的计数
- maven - SonarQube 分析适用于 IDE,但不适用于 Jenkins Pipeline
- ios - 如何生成 Swift *Runtime* 警告消息?
- javascript - 为什么最后一个 console.log 中的侦听器数组长度是 3 而不是 2?
- php - 允许的内存大小 138412032 字节用尽(尝试分配 20480 字节)
- android - 如何使用 onTouchEvent 或任何其他方式在 graphView 上绘制形状?
- java - 如何检测处于僵尸状态的 Kafka Streams 应用程序
- coldfusion - 尝试在 Coldfusion 中设置亚马逊 MWS。超级简单的请求未获得授权
- python - 将 Python 连接到盆景
- node.js - Angular 9 通用为什么只有一半的应用程序用 ngx-translate 翻译?