配置如下:
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="myJob"></property>
<property name="targetMethod" value="progess"></property>
<property name="concurrent" value="false"></property>
</bean>
<bean id="jobCornTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobDetail"></property>
<property name="cronExpression" value="0 0/5 * * * ?"></property>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="jobCornTrigger"/>
</list>
</property>
<property name="autoStartup" value="true"/>
</bean>
启动代码:
public static void main(String[] args) {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
}
我省略了下业务代码
但是放到服务器上,一会儿服务自动退出了,但是本地由于有任务在执行,容器是不关闭的,大家看下可能是什么原因?