Spring @PostConstruct vs. init-method attribute

前端 未结 6 902
攒了一身酷
攒了一身酷 2020-12-04 06:35

Is there any difference between using the @PostConstruct annotation and declaring the same method as init-method in Spring XML configuration?

6条回答
  •  盖世英雄少女心
    2020-12-04 07:05

    @postconstruct is not part of the spring. It is part of javax package. Both are the same. using init-method we need to added in xml file.If you use @postconstruct adding in xml is not required. Check out the below article .

    http://answersz.com/spring-postconstruct-and-predestroy/

提交回复
热议问题