SpringCloud上下文:应用程序上下文服务

自定义Bootstrap配置

通过将项添加到名为org.springframework.cloud.bootstrap.BootstrapConfiguration的项下的/META-INF/spring.factories中.

当添加自定义BootstrapConfiguration,小心你添加类不是@ComponentScanned错误地进入你的“ 主 ”应用程序上下文,这里可能并不需要它们。为引导配置类使用单独的程序包名称,并确保@ComponentScan或带注释的配置类@SpringBootApplication尚未包含该名称。

spring.factories 有一套用法,从spring.factories中找到的类创建引导上下文,会在启动之前,将类型为ApplicationContextInitializer的所有@Beans添加到主SpringApplication

自定义引导程序Property源

中文文档

端点

对于Spring Boot Actuator应用程序,可以使用一些其他管理端点。您可以使用:

  • POST/actuator/env以更新Environment并重新绑定@ConfigurationProperties和日志级别。
  • /actuator/refresh重新加载引导上下文并刷新@RefreshScope beans。
  • /actuator/restart关闭ApplicationContext并重新启动(默认情况下禁用)。
  • /actuator/pause/actuator/resume用于调用Lifecycle方法(ApplicationContext中的stop()start())。
[注意]
如果禁用/actuator/restart端点,则/actuator/pause/actuator/resume端点也将被禁用,因为它们只是/actuator/restart的特例。

本文地址: https://github.com/maxzhao-it/blog/post/29799/