Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
@PreDestroy当 bean 被垃圾回收时,是否调用了原型 bean的方法?
@PreDestroy
不,当 bean 被垃圾收集时它不会被调用,但是要让 bean 被垃圾收集,它必须首先被取消引用,这意味着它必须被销毁并被@PreDestroy调用。
所以该方法不会被直接调用,但它必须在被垃圾收集之前被调用