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.
Loading...
Related Quiz
- To include Spring MVC in a Spring Boot project, the _____ starter dependency should be added.
- In what cases would you choose constructor injection over setter injection, and why?
- How can you handle exceptions thrown by a controller method in a Spring Boot application?
- To include additional configuration files in a Spring Boot project, the _____ property can be used.
- The _____ endpoint in OAuth2 is used by the client to obtain an access token.