What are the steps of a bean's lifecycle? How do BeanPostProcessor and BeanFactoryPostProcessor differ?
Short answer
A bean goes definition → instantiation → injection → callbacks → postProcessAfterInitialization (where AOP proxies are made) → ready → @PreDestroy. BeanFactoryPostProcessor edits metadata before any bean exists; BeanPostProcessor handles each instance.
3 points to say:
- Order: definition → instance → inject → Aware → before-init →
@PostConstruct→ after-init (proxy). - BFPP edits definitions before any bean exists; BPP modifies or wraps each instance.
@PostConstructruns on the raw object, before the proxy; heavy startup work goes in a runner orApplicationReadyEvent.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.