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?
If you want run a job after Spring's context start, then you can use the ApplicationListener
and the event ContextRefreshedEvent
.
public class YourJobClass implements ApplicationListener{
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent ) {
// do what you want - you can use all spring beans (this is the difference between init-method and @PostConstructor where you can't)
// this class can be annotated as spring service, and you can use @Autowired in it
}
}