For my use case, I wanted to invoke a method doSomething()
under three scenarios:
Basically, an application crash is a type of application shutdown. But I am looking for a way to differentiate between the two. I want to pass the exception which has caused the application to crash to doSomething(ex)
as well.
Can I achieve this through ContextClosedEvent
or is there another way to achieve the functionality?
is it ok using @PreDestroy?
import org.springframework.stereotype.Component;
import javax.annotation.PreDestroy;
@Component
public class MyService {
@PreDestroy
public void predestory() {
System.out.println("--------using predestoy-----");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.