@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 .
There 也许吧 difference between @PostConstruct and init-method because @PostConstruct is handled in the postProcessAfterInitialization phase of bean initialization (AbstractAutowireCapableBeanFactory.initializeBean() method) by CommonAnnotationBeanPostProcessor, while init method gets called after the completion of postProcessBeforeInitialization phase (and, for this matter, before the beginning of postProcessAfterInitialization phase). 编辑:
所以,顺序是:
1) postProcessBeforeInitialization phase,
2)调用 init方法,
3) postProcessAfterInitialization phase, which calls @PostConstruct method