简体   繁体   中英

How to get callback when Spring web aplication is finished starting

I have some action I need to perform after the entire spring application has finished loading. The action must happen after all beans are inititlized and all controllers can start serving requests.

I tried implementing a ServletContextListener and adding it as a listener in AbstractAnnotationConfigDispatcherServletInitializer but this happens as soon as the application boot up and not after. Also I am not using SpringBoot avaiable to do this.

Thanks,

Because you are using spring mvc.

So RequestHandledEvent will fulfill your requirement.

RequestHandledEvent

This is a web-specific event telling all beans that an HTTP request has been serviced.

More detail about spring event

https://www.tutorialspoint.com/spring/event_handling_in_spring.htm

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM