1
私は次のメソッド呼び出し動的にしようとしています:。ここで文字列名でクラス参照を取得するには?
The method newJob(Class< ? extends Job>) in the type JobBuilder is not applicable for the arguments (Class< capture#3-of ?>)
:次の操作を実行して、
JobDetail job = newJob(RunMeJob.class)
.withIdentity("myJob", "group1")
.build();
を:
private void scheduleJob(final SchedulerJob job, final SchedulerTrigger trigger) {
final String fullyQualifiedName = "com.crm.scheduler.job.RunMeJob";//"com.crm.scheduler.job" + job.getImplementation();
Class<?> cls = Class.forName(fullyQualifiedName, false, null);
JobDetail jobDetail = newJob(cls)
.withIdentity(job.getExternalReference(), trigger.getExternalReference())
.build();
}
しかし、私は、次のエラーが発生しますRunMeJob
クラス:
package com.crm.scheduler.job;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;
import com.crm.scheduler.task.RunMeTask;
@Component
public class RunMeJob implements Job {
@Override
public void execute(JobExecutionContext arg0) throws JobExecutionException {
new RunMeTask().printMe();
}
}
どのようにクラスを動的に指定できますか?
あなたは 'newJob'の署名を共有できますか? – Mureinik