spring定时任务
2015-11-23 15:11
501 查看
1:依赖的jar包
<!-- spring 定时器所依赖的jar包 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
2:配置文件信息
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- ==============INST每日黑名单数据导出Begin====================== -->
<!-- RDM黑名单即时同步到INST -->
<bean id="quart" class="com.creditease.beehive.employ.controller.EmployController">
</bean>
<bean id="blackDataJobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<!-- 调用的类 -->
<property name="targetObject">
<ref bean="quart"/>
</property>
<!-- 调用类中的方法 -->
<property name="targetMethod" >
<value>Starts</value>
</property>
</bean>
<!-- 触发时间 -->
<bean id="blackDataDoTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="blackDataJobtask"/>
</property>
<!-- cron 表达式 -->
<property name="cronExpression">
<value>0 0/1 * * * ?</value>
</property>
</bean>
<bean id="sfb" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="blackDataDoTime"/> //定时任务列表
</list>
</property>
</bean>
</beans>
<!-- spring 定时器所依赖的jar包 -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.8.5</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
2:配置文件信息
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<!-- ==============INST每日黑名单数据导出Begin====================== -->
<!-- RDM黑名单即时同步到INST -->
<bean id="quart" class="com.creditease.beehive.employ.controller.EmployController">
</bean>
<bean id="blackDataJobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >
<!-- 调用的类 -->
<property name="targetObject">
<ref bean="quart"/>
</property>
<!-- 调用类中的方法 -->
<property name="targetMethod" >
<value>Starts</value>
</property>
</bean>
<!-- 触发时间 -->
<bean id="blackDataDoTime" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref bean="blackDataJobtask"/>
</property>
<!-- cron 表达式 -->
<property name="cronExpression">
<value>0 0/1 * * * ?</value>
</property>
</bean>
<bean id="sfb" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="blackDataDoTime"/> //定时任务列表
</list>
</property>
</bean>
</beans>
相关文章推荐
- 举例解析Java多线程编程中需要注意的一些关键点
- java中抽象类和接口的区别
- Spring Remoting: Remote Method Invocation (RMI)
- Spring中Quartz的配置
- 配置jdk
- Eclipse 优化方法(经典收藏)
- eclipse设置护眼豆沙绿背景色以及字体颜色
- 多图详解Spring框架的设计理念与设计模式
- java中的System.nanoTime与System.currentTime
- ubuntu下安装jre,Eclipse, CDT
- java.io.IOException: error=24, 打开的文件过多
- Java贪吃蛇的简单实现
- eclipse ---修改新建jsp模板
- JAVA 正则表达式 (超详细)
- 【转】The import javax.servlet cannot be resolved
- java环境变量配置问题
- The import java.io cannot be resolved
- java读取ipa、apk文件中的配置信息
- java split
- 关于多个的线程操作文件 文件句柄(java中得文件流)