我知道的特定原因是因为实例化了QuartzJob类,但是我知道使用了不带参数的构造函数,然后调用execute
方法来报告异常。 @Inject
不起作用。
打印的错误消息:
org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: java.lang.NullPointerException
at org.openscoring.service.quartz.QuartzJob.execute(QuartzJob.java:36)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
... 1 more
QuartzJob实现Job接口
@Service
@Singleton
public class QuartzJob implements Job {
@Inject
private SynchronousCache synchronousCache;
@Override
public void execute(JobExecutionContext content) {
System.out.println(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())+ "★★★★★★★★★★★");
synchronousCache.synchronizationModel();
}
}
QuartzManager.addJob("test", QuartzJob.class, "10/59 * * * * ? *");
添加定时任务