首页 > 解决方案 > spring boot 中生命周期阶段号的来源

问题描述

停止 SpringBoot 应用程序时,可以看到如下所示的 INFO 日志消息。那个阶段数是从哪里来的?

o.s.c.support.DefaultLifecycleProcessor  : Stopping beans in phase 2147483647

标签: spring-bootspring-framework-beans

解决方案


Spring Framework 在org.springframework.context.SmartLifecycle接口中默认将该值设置为 2147483647

int DEFAULT_PHASE = Integer.MAX_VALUE;

确认:

jshell> Integer.MAX_VALUE
$1 ==> 2147483647

推荐阅读