在云配置客户端上重新启动POST
后,将创建一个新的ConfigServicePropertySourceLocator
并保留旧的POST
。问题是,它们都是在重启后调用的,所以如果我GET
重启10次,我会得到11个bean 和 11个调用,这会导致11 SpringApplication#addInitializers(ApplicationContextInitializer<?>... initializers)
个调用配置服务器。
this = {SpringApplication@2244}
initializers = {ApplicationContextInitializer[2]@6093}
0 = {PropertySourceBootstrapConfiguration$$EnhancerBySpringCGLIB$$56dce074@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$$56dce074@3705}
8 = {EnvironmentDecryptApplicationInitializer@3706}
9 = {BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer@3715}
PropertySourceBootstrapConfiguration
如您所见,它将在initializer
列表中添加另一个 return $helpers->json(array(
"status" => "error",
"data" => "Send json with post !!"
));
实例。
导致这种情况的原因是什么,我该如何避免呢?
答案 0 :(得分:1)
这似乎是一个已知问题 - 在GitHub上记录了一个错误:https://github.com/spring-cloud/spring-cloud-commons/issues/138 - 创建了一个项目来重现问题(https://github.com/nicolaferraro/spring-cloud-context-example),它似乎是相当普遍。