spring Quartz定时器需要的jar包 要是有个具体例子更好 发到891950969@qq.com谢谢 5
2个回答
展开全部
需要这个:quartz-1.6.2.jar
下面是触发器配置文件,把该文件引用到application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 定时器配置 -->
<!-- 配置定时器类 -->
<bean id="triggerUtil" class="com.pro.base.util.TriggerUtil" >
</bean>
<!-- 指定任务(方法) -->
<bean id="expDataBaseJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref local="triggerUtil" />
</property>
<property name="targetMethod">
<value>expDataBase</value>
</property>
</bean>
<!-- 设定计划执行时间 -->
<bean id="expDataBaseTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref local="expDataBaseJob" />
</property>
<property name="cronExpression">
<value>00 33 21 * * ?</value>
</property>
</bean>
<!-- 任务执行器配置 -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="expDataBaseTrigger" />
</list>
</property>
</bean>
</beans>
Java类:
public class TriggerUtil {
@Resource(name = "basicService")
private BasicService service; //数据库操作服务
private TriggerUtil(){
}
public void expDataBase(){
System.out.println("trigger actived........");
System.out.println("=========================="+service+"");
String command="exp ";
}
public BasicService getService() {
return service;
}
public void setService(BasicService service) {
this.service = service;
}
}
下面是触发器配置文件,把该文件引用到application.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!-- 定时器配置 -->
<!-- 配置定时器类 -->
<bean id="triggerUtil" class="com.pro.base.util.TriggerUtil" >
</bean>
<!-- 指定任务(方法) -->
<bean id="expDataBaseJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref local="triggerUtil" />
</property>
<property name="targetMethod">
<value>expDataBase</value>
</property>
</bean>
<!-- 设定计划执行时间 -->
<bean id="expDataBaseTrigger"
class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref local="expDataBaseJob" />
</property>
<property name="cronExpression">
<value>00 33 21 * * ?</value>
</property>
</bean>
<!-- 任务执行器配置 -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="expDataBaseTrigger" />
</list>
</property>
</bean>
</beans>
Java类:
public class TriggerUtil {
@Resource(name = "basicService")
private BasicService service; //数据库操作服务
private TriggerUtil(){
}
public void expDataBase(){
System.out.println("trigger actived........");
System.out.println("=========================="+service+"");
String command="exp ";
}
public BasicService getService() {
return service;
}
public void setService(BasicService service) {
this.service = service;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
发过去了~ 看看吧~
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询