Spring Bean lifecycle events – Annotation based

You can use spring annotation to implement Spring Bean lifecycle events firing methods. This is JSR-250 life-cycle annotation @PostConstruct and @PreDestroy

I have added above two anotation in this Bean class

You can have the following xml file with

To test the above code you use the following main method

You can see the following output