@PostConstruct annotation and spring lifecycle

后端 未结 2 2072
抹茶落季
抹茶落季 2020-12-29 04:47

I\'m new to Spring, I would like to know:

I have a java class annotated with @Component (spring) and inside I have a method annotated with @PostC

2条回答
  •  清歌不尽
    2020-12-29 05:08

    The handling of annotations such as @PostConstruct, @Resource, @PreDestroy is done via a BeanPostProcessor, in this case the CommonAnnotationBeanPostProcessor. You can see in the following diagram from Spring that these BPP's are handled after Dependency Injection but before Bean Ready For Use (Which means as much as injectable).

提交回复
热议问题