NutzCN Logo
问答 关于quart无反应的问题
发布于 2707天前 作者 老司机 1506 次浏览 复制 上一个帖子 下一个帖子
标签:

job类代码

package com.amax.quartz.job;

import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.Files;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import java.io.IOException;
import java.util.Date;

/**
 * Created by shawn_xiao on 2016/12/2.
 */
@IocBean
public class TestJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        try {
            Files.createFileIfNoExists("D:/"+new Date().toString()+".txt");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

custom/cron.properties里面

cron.com.amax.quartz.job.TestJob=0 0/2 * * * ?

mainsetup

  public void init(NutConfig conf) {
        Ioc ioc = conf.getIoc();
        // 获取NutQuartzCronJobFactory从而触发计划任务的初始化与启动
        ioc.get(NutQuartzCronJobFactory.class);
//        Http.get("localhost:8688/amax_test/init");
    }

添加quart后
日志显示它也在扫描但是没有任何反应,也不执行execute,也不报错求解

2016-12-02 17:39:13,772 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers
2016-12-02 17:39:41,897 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers
2016-12-02 17:40:08,426 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers
2016-12-02 17:40:31,439 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers
2016-12-02 17:40:55,844 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers
2016-12-02 17:41:22,978 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers
2016-12-02 17:41:50,459 [org.quartz.core.QuartzSchedulerThread]-[DEBUG] batch acquisition of 0 triggers

1 回复

一般原因是没读到这个配置文件, 下面的代码可以检查

String str = ioc.get(PropertiesProxy.class, "conf").get("cron.com.amax.quartz.job.TestJob");

贴一下dao.js或者conf所在的配置文件吧

添加回复
请先登陆
回到顶部