How to execute jobs just after spring loads application context?

后端 未结 5 1484
萌比男神i
萌比男神i 2021-02-01 03:14

I want to run some jobs just after loading the Spring context but I do not know how to do this.
Do you have any idea how to do that?

5条回答
  •  失恋的感觉
    2021-02-01 03:47

    You can write a bean class that implements the org.springframework.context.Lifecycle interface. Add this bean to your context, and the start() method will be invoked by the container once that context has finished starting up.

提交回复
热议问题