0

我正在尝试使用 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 作业,以便更好地理解。

4

0 回答 0