Spring - stop bean initialization
-
12-06-2021 - |
Question
My bean implements InitializingBean and in the afterPropertiesSet method I want to perform validation.
The thing is that my validation uses some other bean which are not totaly finished loaded at this point, beans like JPA beans..
I used also @PostConstruct
annotation - this is even worse since this method invoke before the afterPropertiesSet
method.. Any suggestion how to solve this issue ?
Solution
I solve my problem by implementing PostInit annotation
the annotation insure that the method that using this annotation will be invoke only after all beans
within the application have been deployed.
good reference: http://reteptools.kenai.com/api/retepMicroKernel/snapshot/uk/org/retep/kernel/annotations/PostInit.html
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow