首页 > 试题广场 >

在Spring Boot项目中,某Bean同时实现了Init

[单选题]
在Spring Boot项目中,某Bean同时实现了InitializingBean接口(重写afterPropertiesSet方法)、使用@PostConstruct注解标记了初始化方法,以及在@Bean注解中通过init-method属性指定了自定义初始化方法。关于这三个初始化逻辑的执行顺序,以下说法正确的是?
  • @PostConstruct → afterPropertiesSet → init-method
  • init-method → afterPropertiesSet → @PostConstruct
  • afterPropertiesSet → @PostConstruct → init-method
  • @PostConstruct → init-method → afterPropertiesSet
Spring 的设计理念是: 注解优先于接口,接口优先于 XML/配置属性
发表于 2025-11-04 22:29:22 回复(0)