Search code examples
spring-bootspring-framework-beans

Where the lifecycle phase number comes from in spring boot


When stopping a SpringBoot application, INFO log messages like the one below can be witnessed. Where that phase number comes from?

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

Solution

  • That value is set to 2147483647 by default by Spring Framework in org.springframework.context.SmartLifecycle interface

    int DEFAULT_PHASE = Integer.MAX_VALUE;
    

    Verification:

    jshell> Integer.MAX_VALUE
    $1 ==> 2147483647