spring-cloud-config 客户端在 spring-cloud-config 服务器未就绪时启动失败

spring-cloud-config client failed to start when spring-cloud-config server not ready

这里我用了rancherdocker-compose来初始化spring- cloud-config 客户端和服务器,但是当spring-cloud-config server 没有准备好时,client启动失败,需要在服务器准备好后重新启动。 我想问有什么机制可以让spring-cloud-config client在服务器准备好后重新加载或重启?

最后,在研究 http://cloud.spring.io/spring-cloud-config/spring-cloud-config.html#_client_side_usage 之后,spring 云配置重试部分,我找到了这些答案:

Config Client Retry If you expect that the config server may occasionally be unavailable when your app starts, you can ask it to keep trying after a failure. First you need to set spring.cloud.config.failFast=true, and then you need to add spring-retry and spring-boot-starter-aop to your classpath. The default behaviour is to retry 6 times with an initial backoff interval of 1000ms and an exponential multiplier of 1.1 for subsequent backoffs. You can configure these properties (and others) using spring.cloud.config.retry.* configuration properties. TIP To take full control of the retry add a @Bean of type RetryOperationsInterceptor with id "configServerRetryInterceptor". Spring Retry has a RetryInterceptorBuilder that makes it easy to create one.

因此:

spring:
   cloud:
     config:
       fail-fast: true
     retry:
       max-attempts: 10000
       max-interval: 1000