重启后 Config Server 的多个请求

Multiple Requests at Config Server after Restart

POST 在云配置客户端上重新启动后,将创建一个新的 ConfigServicePropertySourceLocator,并保留旧的。问题是,它们都是在重启后调用的,所以如果我 POST 重启 10 次,我得到 11 个 bean 11 次调用,结果是 11 GET 调用配置服务器。

断点在 SpringApplication#addInitializers(ApplicationContextInitializer<?>... initializers)

this = {SpringApplication@2244} 
initializers = {ApplicationContextInitializer[2]@6093} 
 0 = {PropertySourceBootstrapConfiguration$$EnhancerBySpringCGLIB$dce074@6097} 
 1 = {EnvironmentDecryptApplicationInitializer@6098} 
this.initializers = {ArrayList@3671}  size = 10
 0 = {DelegatingApplicationContextInitializer@3784} 
 1 = {ContextIdApplicationContextInitializer@3785} 
 2 = {ConfigurationWarningsApplicationContextInitializer@3786} 
 3 = {ServerPortInfoApplicationContextInitializer@3787} 
 4 = {SharedMetadataReaderFactoryContextInitializer@3788} 
 5 = {AutoConfigurationReportLoggingInitializer@3789} 
 6 = {BootstrapApplicationListener$AncestorInitializer@3678} 
 7 = {PropertySourceBootstrapConfiguration$$EnhancerBySpringCGLIB$dce074@3705} 
 8 = {EnvironmentDecryptApplicationInitializer@3706} 
 9 = {BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer@3715} 

如您所见,即将向 initializer 列表中添加 PropertySourceBootstrapConfiguration 的另一个实例。

可能是什么原因造成的,我该如何避免?

这似乎是一个已知问题 - 在 GitHub 上记录了一个错误:https://github.com/spring-cloud/spring-cloud-commons/issues/138 - there's a project created to reproduce the issue (https://github.com/nicolaferraro/spring-cloud-context-example),这似乎是相当普遍的问题。