当我从属性存储库更改值并重新启动Spring Cloud Config Server时,更改不会反映其消费者。
我-微服务/ application.properties:
spring.application.name=my-service
spring.cloud.config.uri=http://localhost:8888
my service controller.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());
}
}
弹簧云配置服务器/ application.properties
server.port=8888
spring.application.name=spring-cloud-config-server
spring.cloud.config.server.git.uri=file://path
Git回购
没有-service.properties
my-service.propertie1=1
my-service.propertie2=2
当我向localhost:8080 / my-service发送GET请求时,这就是我得到的结果:
{
"propertie1":1,
"propertie2":2
}
好的,没关系!但是,如果我更改my-service.properties
并重新启动我的Spring Cloud Config Server,则更改不会反映MyServiceController
。我需要重新启动my-microservice应用程序,以使更改生效。这是正常行为吗?我的意思是,如果这是远程的,那么应该配置是否要缓存。
为了更新配置,我向POST
发送了localhost:8080/actuator/refresh
请求。
默认情况下,/refresh
不会在执行器端点中暴露。
我在application.properties中暴露了以下行:
management.endpoints.web.exposure.include=*
然后,向上面的端点发送没有正文的POST
请求。