1
我想用石英和春天運行一項工作,但不運行的工作,並沒有得到控制檯上的錯誤。作業保存在mysql中,但不能運行。春天 - 石英沒有執行jobclass
我的配置是
- 彈簧4.0.6
- 石英2.2.1
的applicationContext.xml
<bean id="scheduler" name="scheduler"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean"
scope="singleton">
<property name="quartzProperties">
<props>
<prop key="org.quartz.scheduler.instanceId">AUTO</prop>
<prop key="org.quartz.scheduler.instanceName">MyClusteredScheduler</prop>
<prop key="org.quartz.jobStore.class">org.quartz.impl.jdbcjobstore.JobStoreTX</prop>
<prop key="org.quartz.jobStore.driverDelegateClass">org.quartz.impl.jdbcjobstore.StdJDBCDelegate</prop>
<prop key="org.quartz.jobStore.tablePrefix">QRTZ_</prop>
<prop key="org.quartz.jobStore.isClustered">true</prop>
<prop key="org.quartz.jobStore.clusterCheckinInterval">20000</prop>
<prop key="org.quartz.jobStore.misfireThreshold">60000</prop>
</props>
</property>
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/test" />
<property name="username" value="*****" />
<property name="password" value="*****" />
</bean>
的MyJob類
public class MyJob implements Job, Serializable{
private static final long serialVersionUID = -1750295779628942902L;
public void execute(JobExecutionContext context) throws JobExecutionException {
System.out.println("run job run!!!");
}
}
主要測試類
public static void main(String[] args) {
ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext("applicationContext.xml");
StdScheduler stdScheduler= (StdScheduler) context.getBean("scheduler");
MyJob myJob= (MyJob) context.getBean("myJob");
try {
JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("triggerUno10").build();
Trigger trigger= TriggerBuilder.newTrigger().withIdentity("triggerUno10").withSchedule(
CronScheduleBuilder.cronSchedule("0/5 * * * * ?")).forJob(jobDetail).build();
stdScheduler.start();
stdScheduler.scheduleJob(jobDetail, trigger);
} catch (Exception e) {
e.printStackTrace();
}
}