spring2.5+quartz1.6.5配置

在网上找spring+quartz的配置文档都是针对spring2.0版本的,用2.5会莫名其妙的出错,2.5版本的配置如下:

applicationContext-scheduler.xml:

<!-- 定时任务 -->
<bean id="schedulerFactoryBean" lazy-init="false" autowire="no"
class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="doTime"/>
</list>
</property>
<property name="configLocation" value="classpath:quartz.properties"/>
</bean>

<!-- 定义触发时间 -->
<bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="a"/>
</property>
<!-- cron表达式 -->
<property name="cronExpression">
<value>0/5 * * * * ?</value>
</property>
</bean>

<!-- 指定时间工作的类 -->
<bean id="a" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>com.eway.payweb.scheduler.TestCheck</value>
</property>


</bean>


quartz.properties:

org.quartz.scheduler.instanceName = Sched1
org.quartz.scheduler.instanceId = 1
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false

org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 3

org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore


TestCheck:

public class TestCheck extends QuartzJobBean{

public TestCheck(){

}


@Override
public void executeInternal(JobExecutionContext context)
throws JobExecutionException {
JobDetail job= context.getJobDetail();
System.out.println(new Date()+":"+job.getName());

}

}


QuartzTest:

public class QuartzTest {



// @Override
// protected String[] getConfigLocations() {
// return new String[] { "classpath:/applicationContext.xml", "classpath:/applicationContext-scheduler.xml" };
// }


public static void main(String [] argo){
System.out.println("Test start.");
ApplicationContext context=new ClassPathXmlApplicationContext("applicationContext-scheduler.xml");
System.out.print("Test end..");

}


}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值