更新时间:2023-02-19 23:23:56
Interesting Question. I'd say you should be able to do it by letting your bean implement SmartLifeCycle
.
这样,如果您的int getPhase();
方法返回Integer.MAX_VALUE
,它将在ApplicationContext
最终关闭时成为第一个被调用的对象.
That way, if your int getPhase();
method returns Integer.MAX_VALUE
, it will be among the first to be called when the ApplicationContext
finally shuts down.
参考:
SmartLifeCycle
javadocs