SPRING quartz定时器每天晚上会执行4次,求大师帮忙看看是什么原因~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
代码如下:
<!-- 每日凌晨0点0分0秒启动定时器 -->
<bean id="cronReportTriggerDay" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="jobDayTask" />
<property name="cronExpression">
<value>0 0 0 * * ?</value>
</property>
</bean>
<bean id="jobDayTask" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.sp2p.task.JobDayTask"></property>
</bean>
public class JobDayTask extends QuartzJobBean {
private static Log log = LogFactory.getLog(JobDayTask.class);
private static boolean isRunning = false;
private Object getBean(String beanName) {
return ContextLoader.getCurrentWebApplicationContext().getBean(beanName);
}
private Object getApplicationMap(String attrName){
return ContextLoader.getCurrentWebApplicationContext().getServletContext().getAttribute(attrName);
}
private void setApplicationMap(String attrName,Map<String,String> map){
ContextLoader.getCurrentWebApplicationContext().getServletContext().setAttribute(attrName, map);
}
@SuppressWarnings("unchecked")
@Override
protected void executeInternal(JobExecutionContext arg0)
throws JobExecutionException {
long start = System.currentTimeMillis();
//获取平台收费
Map<String,Object> platformCostMap = (Map<String, Object>) getApplicationMap(IAmountConstants.FEE_APPLICATION);
FrontMyPaymentService frontMyPayment = (FrontMyPaymentService) getBean("frontpayService");
JobTaskService jobTaskService = (JobTaskService) getBean("jobTaskService");
try {
Map<String,String> investMap = frontMyPayment.querInvesttou();
setApplicationMap("investMap", investMap);//放入全局变量中 用于前台二级菜单 金额的显示
if(!isRunning){
isRunning = true;
jobTaskService.autoPromoteIncome();
log.info("每日任务处理结束NEW");
isRunning = false;
}
} catch (Exception e) {
e.printStackTrace();
}finally{
platformCostMap = null;
}
log.info("用时 : " + (System.currentTimeMillis() - start) + "毫秒"
+"SystemMemery:freeMemory"+Runtime.getRuntime().freeMemory()+"-------maxMemory"+Runtime.getRuntime().maxMemory()+"-------totalMemory"+Runtime.getRuntime().totalMemory());
}
}