您能否在刷新时验证应用程序链接是否已获取主机名和应用程序名称。因为在 localhost 中进行刷新时,它只是本地的 springboot 应用程序,因此不需要额外的 application-name 路径。当您通常部署到服务器时,除了主机名之外,我们还必须提供应用程序的路径名。在tomcat中,我使用的网址如下,
http://<hostname>/**<application-name>**/actuator/refresh/
通常,当您通过邮递员访问此 URL 时,它会给您一个 200 响应,其中包含一个空的 [] 正文。然后,您应该能够在客户端应用程序的日志文件中看到以下行。 [我还在应用程序的 main 方法中设置了属性 @RefreshScope 属性,就在 @SpringBootApplication 属性的下方,用于刷新应用程序的属性。]
INFO o.s.c.c.c.ConfigServicePropertySourceLocator.getRemoteEnvironment:249 - Fetching config from server at : http://<hostname>/<Config-server-application-name>/
INFO o.s.c.c.c.ConfigServicePropertySourceLocator.log:168 - Located environment: name=config-client, profiles=[development], label=null, version=ab36989c85922f1c9cf7803fac4, state=null
INFO o.s.c.b.c.PropertySourceBootstrapConfiguration.initialize:112 - Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://<gitlaburl>/<companyname>/config-server.git/config-client-development.yml'}]
INFO o.s.boot.SpringApplication.logStartupProfileInfo:655 - The following profiles are active: development
INFO o.s.boot.SpringApplication.logStarted:61 - Started application in 1.557 seconds (JVM running for 70689.032)
对于 Kubernetes,
尝试使用
kubectl 应用
(而不是 kubectl 创建配置映射。)
要部署配置映射,只需在 Kubernetes 上运行以下命令:
kubectl apply -f config-map.yml
确保配置映射的名称与 Spring Boot 应用程序的名称匹配。另请参阅下面的链接,
https://github.com/spring-cloud/spring-cloud-kubernetes/issues/255
还有一个 spring cloud kuberenetes,您可以如下探索,
https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernetes/2.0.0.M1/reference/html/#why-do-you-need-spring-cloud-kubernetes