Reputation: 916
I have a couple questions about @PostConstruct in Spring.
I will be grateful for the answers)
Upvotes: 1
Views: 803
Reputation: 360
@PostConstruct is thread safe. It only runs once after the bean created in the whole lifecycle of the bean.
Upvotes: 0
Reputation: 42441
Yes, Spring calls @PostConstruct
marked methods the object before it gets available to the application (Before injection). This is a part of bean creation.
No. Spring creates an internal structure called "bean definition" during the application context initialization. Its a meta data about the bean. If the bean has "post-construct" method spring knows this and calls the relevant method during the bean creation.
Upvotes: 2