When defining a bean, the _____ annotation can be used to specify the method to invoke when the application context is closed.

  • @OnClose
  • @PreDestroy
  • @DestroyMethod
  • @PostConstruct
In Spring, the "@PreDestroy" annotation can be used to specify a method that should be invoked when the application context is closed or when the bean is being destroyed. This allows you to perform cleanup tasks or release resources associated with the bean. The other options are related to lifecycle methods but do not serve this specific purpose.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *