泽西集成石英@Inject注释不起作用

时间:2018-07-13 03:56:45

标签: quartz-scheduler jersey-2.0

我知道的特定原因是因为实例化了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 * * * * ? *");

添加定时任务

0 个答案:

没有答案