我试图使用struts 2框架使用cron作业。我试过mkyong中的这个例子 为了理解。来源如下,
//SchedulerJob.java
public class SchedulerJob implements Job {
public void execute(JobExecutionContext context)throws JobExecutionException {
System.out.println("Struts 2.3.4 + Quartz 2.1.5");
}}
//QuartzSchedulerListener.java
public class QuartzSchedulerListener implements ServletContextListener {
public void contextDestroyed(ServletContextEvent arg0) {//....}
public void contextInitialized(ServletContextEvent arg0) {
JobDetail job = JobBuilder.newJob(SchedulerJob.class).withIdentity("anyJobName", "group1").build();
//.....}}
在JobDetail
行中收到错误说明
no suitable method found for newJob(Class<SchedulerJob>)
method JobBuilder.newJob(Class<? extends Job>) is not applicable
(actual argument Class<SchedulerJob> cannot be converted to Class<? extends Job> by method invocation conversion)
method JobBuilder.newJob() is not applicable
(actual and formal argument lists differ in length)
建议我解决这个问题。让我知道是否有任何样本源可用于使用struts 2的cron作业以便更好地理解。