我想在加载Spring上下文后立即运行一些作业,但是我不知道该怎么做。 你有什么想法吗?
谢谢大家的答复。实际上,我错过了一个问题的细节,我想在加载应用程序上下文后立即运行Quartz Job。我尝试了解决方案stakfeman,但是在运行Quartz Jobs时遇到了一些问题。最后,我找到了解决方案:在Spring中使用Quartz,代码如下:
<!-- ===========================Quartz configuration==================== --> <bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject" ref="processLauncher" /> <property name="targetMethod" value="execute" /> </bean> <bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean"> <!-- see the example of method invoking job above --> <property name="jobDetail" ref="jobDetail" /> <!-- 10 seconds --> <property name="startDelay" value="10000" /> <!-- repeat every 50 seconds --> <property name="repeatInterval" value="50000" /> </bean> <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="simpleTrigger" /> </list> </property> </bean>
再次感谢您的帮助,如果问题不是很清楚,我深表歉意’:(