当我更改属性存储库中的值并重新启动时,这些更改不会反映它的使用者。
my-microservice/application.properties:
spring.application.name=my-service
spring.cloud.config.uri=http://localhost:8888MyServiceController.java
@RestController
public class MyServiceController {
@Autowired
private Configuration configuration;
@GetMapping("/my-service")
public MyServiceBean retrieveMyServiceProperties() {
// show propertie's values
return new MyServiceBean(configuration.getPropertie1(), configuration.getPropertie2());
}
}spring-cloud-config-server/application.properties
server.port=8888
spring.application.name=spring-cloud-config-server
spring.cloud.config.server.git.uri=file://pathGit回购
my-service.properties
my-service.propertie1=1
my-service.propertie2=2当我向localhost:8080/my-service,发送GET请求时,我得到的结果是:
{
"propertie1":1,
"propertie2":2
}好吧,没关系!但是,如果我更改了my-service.properties并重新启动了,这些更改会使而不是反映MyServiceController。我确实需要重新启动我的-microservice应用程序,以使更改生效。这是正常行为吗?我的意思是,如果这是远程的,那么应该配置它是否缓存。
发布于 2018-09-10 18:05:40
为了更新配置,我向POST发送了一个localhost:8080/actuator/refresh请求。
默认情况下,/refresh不会在执行器端点中公开。
我在application.properties中公开了以下行:
management.endpoints.web.exposure.include=*然后,向上面的端点发送一个没有POST主体的请求。
发布于 2020-01-08 12:28:46
要更新客户端应用程序,最好使用像RabbitMQ或Apache这样的消息代理。这一进程有三个层次:
简而言之,我们可以使用发布子模型来更新客户端应用程序。

https://stackoverflow.com/questions/52262547
复制相似问题