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重新加载引导上下文并刷新@RefreshScopebeans。/actuator/restart关闭ApplicationContext并重新启动(默认情况下禁用)。/actuator/pause和/actuator/resume用于调用Lifecycle方法(ApplicationContext中的stop()和start())。
![]() |
|---|
如果禁用/actuator/restart端点,则/actuator/pause和/actuator/resume端点也将被禁用,因为它们只是/actuator/restart的特例。 |
![[注意]](/blog/uploads/images/note.png)