一个 Bean 同时使用了 @PostConstruct 方法、实现了 InitializingBean,并在 @Bean 上配置了 initMethod,三者的执行顺序是?
Spring / Java Web
- A.initMethod → afterPropertiesSet → @PostConstruct,自定义方法优先
- B.@PostConstruct → afterPropertiesSet → initMethod
- C.afterPropertiesSet → @PostConstruct → initMethod,接口回调优先
- D.按三个方法在源码中的声明位置从上到下依次执行