关注JEECG发展历程 关注最新动态和版本, 记录JEECG成长点滴 更新日志 - 技术支持 - 招聘英才

JEECG最新版本下载 JEECG智能开发平台 - 显著提高开发效率 常见问题 - 入门视频 - 参与开源团队

商务QQ: 69893005、3102411850 商务热线(5*8小时): 010-64808099 官方邮箱: jeecgos@163.com

查看: 7452|回复: 3

定时任务启动,但是后台只执行了一次

[复制链接]
发表于 2019-6-24 13:37:16 | 显示全部楼层 |阅读模式
定时任务启动,但是后台只执行了一次,求大神帮忙看看,问题出在哪里
 楼主| 发表于 2019-6-24 13:42:56 | 显示全部楼层
  1. @Slf4j
  2. public class TenancyInfoJob implements Job {

  3.     @Autowired
  4.     private IAmTenancyInfoService iAmTenancyInfoService;

  5.     /**
  6.      * 若参数变量名修改 QuartzJobController中也需对应修改
  7.      */
  8.     private String parameter;

  9.     public void setParameter(String parameter) {
  10.         this.parameter = parameter;
  11.     }

  12.     @Override
  13.     public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

  14.         // 使得job对象可以通过注解实现依赖注入
  15.         SpringBeanAutowiringSupport.processInjectionBasedOnCurrentContext(this);

  16.         //查询是否有数据到期
  17.         List<AmTenancyInfo> amTenancyInfos = new ArrayList<AmTenancyInfo>();
  18.         System.out.println("执行定时任务==========TenancyInfoJob=========");

  19.         amTenancyInfos = iAmTenancyInfoService.hasDueData(this.parameter);
  20.         if(amTenancyInfos.size()>0){
  21.             //有需要提醒推送的数据,保存
  22.             amTenancyInfos.forEach(amTenant -> {
  23.                 log.info(amTenant.toString());

  24.                 //将信息保存到sys_qutz_msg记录表中

  25.             });

  26.         }else{
  27.             //没有需要推送的消息

  28.         }

  29.         log.info(String.format("welcome %s! Jeecg-Boot 带参数定时任务 TenancyInfoJob !   时间:" + DateUtils.now(), this.parameter));

  30.     }
  31. }
复制代码
这是我按照jeecg框架里写的一个job,但是通过接口添加quartz任务后,只有添加后执行了一次job,之后就不执行了,请问是还需要修改或者添加什么吗?
 楼主| 发表于 2019-6-26 13:53:39 | 显示全部楼层
2019-06-26 13:29:44.724 [main] INFO  o.s.scheduling.quartz.SchedulerFactoryBean:700 - Starting Quartz Scheduler now
2019-06-26 13:29:45.018 [main] INFO  o.s.scheduling.quartz.LocalDataSourceJobStore:866 - Freed 0 triggers from 'acquired' / 'blocked' state.
2019-06-26 13:29:45.085 [main] INFO  o.s.scheduling.quartz.LocalDataSourceJobStore:876 - Recovering 0 jobs that were in-progress at the time of the last shut-down.
2019-06-26 13:29:45.085 [main] INFO  o.s.scheduling.quartz.LocalDataSourceJobStore:889 - Recovery complete.
2019-06-26 13:29:45.099 [main] INFO  o.s.scheduling.quartz.LocalDataSourceJobStore:896 - Removed 0 'complete' triggers.
2019-06-26 13:29:45.114 [main] INFO  o.s.scheduling.quartz.LocalDataSourceJobStore:901 - Removed 0 stale fired job entries.
2019-06-26 13:29:45.139 [main] INFO  org.quartz.core.QuartzScheduler:547 - Scheduler quartzScheduler_$_NON_CLUSTERED started.
发表于 2019-6-26 14:01:51 | 显示全部楼层
自己跟代码看看吧,建议升级到最新版本
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表