To expand on the @PostConstruct
suggestion in other answers, this really is the best solution, in my opinion.
- It keeps your code decoupled from the Spring API (
@PostConstruct
is in javax.*
)
- It explicitly annotates your init method as something that needs to be called to initialize the bean
- You don't need to remember to add the init-method attribute to your spring bean definition, spring will automatically call the method (assuming you register the annotation-config option somewhere else in the context, anyway).