使用Quartz时出现的错误

错误:
信息: Reloading Context with name [/sjzlgl] is completed
2016-11-25 15:18:54,194 DEBUG [org.quartz.utils.ExceptionHelper] - Detected JDK support for nested exceptions.
2016-11-25 15:18:54,204 ERROR [org.quartz.core.ErrorLogger] - An error occured instantiating job to be executed. job= 'DEFAULT.jobDetailBean'
org.quartz.SchedulerException: Job instantiation failed [See nested exception: java.lang.NullPointerException]
at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:61)
at org.quartz.core.JobRunShell.initialize(JobRunShell.java:132)
at org.quartz.core.QuartzSchedulerThread.run(QuartzSchedulerThread.java:386)
Caused by: java.lang.NullPointerException
at org.springframework.scheduling.quartz.AdaptableJobFactory.createJobInstance(AdaptableJobFactory.java:79)
at org.springframework.scheduling.quartz.AdaptableJobFactory.newJob(AdaptableJobFactory.java:57)
... 2 more
2016-11-25 15:18:54,204 INFO [org.quartz.simpl.RAMJobStore] - All triggers of Job DEFAULT.jobDetailBean set to ERROR state.
2016-11-25 15:19:00,005 DEBUG [org.quartz.core.JobRunShell] - Calling execute on job DEFAULT.StartJob

配置文件

<?xml version="1.0" encoding="UTF-8"?>
- - - - - - - -

Job类和demo类
job:
package com.ym.backadmin.testQuartz;

import java.text.SimpleDateFormat;
import java.util.Date;

public class GetNowDate {
public String getDate(){
return new SimpleDateFormat("yyyy-MM-DD HH:mm:ss").format(new Date());
}
}

demo:
package com.ym.backadmin.testQuartz;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class QuartzDemo extends QuartzJobBean{
private GetNowDate getNowDate;

public GetNowDate getGetNowDate() {
    return getNowDate;
}

public void setGetNowDate(GetNowDate getNowDate) {
    this.getNowDate = getNowDate;
}

@Override
protected void executeInternal(JobExecutionContext context)
        throws JobExecutionException {

    System.out.println(getNowDate.getDate()+":已经进行了QuartzDemo测试");
}

}

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问