石英你好工作
2022-09-02 05:29:18
我是 Quartz 的新手,遇到了编译错误。我只是试图让HelloJob基于Quartz的Hello World第1课运行。我在声明a时遇到麻烦,错误:在类型中不适用于参数(类)”。JobDetail
The method newJob(Class<? extends Job>)
JobBuilder
最初,代码在 、 处有 3 个错误,并且newJob
newTrigger
simpleSchedule
// define the job and tie it to our HelloJob class
JobDetail job = newJob(HelloJob.class)
.withIdentity("job1", "group1")
.build();
// Trigger the job to run now, and then repeat every 40 seconds
Trigger trigger = newTrigger()
.withIdentity("trigger1", "group1")
.startNow()
.withSchedule(simpleSchedule()
.withIntervalInSeconds(40)
.repeatForever())
.build();
没有JobBuilder.newJob(...),TriggerBuilder.newTrigger(...),SimpleScheduleBuilder.simpleSchedule(...)。与给出的示例不同,我继续添加导入,并将类调用附加到newJob,newTrigger等前面,这些调用消除了2/3错误。但似乎错误仍然存在
JobDetail job = JobBuilder.newJob(HelloJob.class)
.withIdentity("job1", "group1")
.build();
我也尝试过将我的工作声明替换为
JobDetail job = new JobDetail("job1", "group1", HelloJob.class);
但这以结束,似乎有几个例子可以做到这一点。Cannot instantiate the type JobDetail
真的会很感激澄清,
谢谢!