@Value
is injected during the Bean Instantiation Phase, not the ApplicationContext Load Phase.Spring's lifecycle can be divided into these key phases:
Phase | What Happens? |
---|---|
ApplicationContext Load Phase | Spring scans for Beans (@Component , @Service , @Repository , @Configuration ) and loads configurations. |
Bean Instantiation Phase | Spring creates Beans and injects dependencies (@Autowired , @Value ). |
Post-Initialization Phase | Spring calls @PostConstruct and executes lifecycle callbacks. |
Application Running Phase | The app is now ready to handle requests. |
📌 @Value
injection happens after the Bean is instantiated, but before @PostConstruct
is executed.