quartz定时任务编写
quartz配置
pom.xml
pom文件需要引入quartz的jar包
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>1.7.2</version>
</dependency>
quartz.properties
quartz.properties文件主要就是用来配置定时任务的开关和定时任务的触发时间
quartz定时任务时间设置 请百度
#定时任务总开关
master.switch=on
#自动评价定时任务
eval.switch=on
#每天0点触发
eval.trigger=0 0 0 * * ?
spring_quartz.xml
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local=EvalTaskCronTriggerBean" />
</list>
</property>
</bean>
<!-- =====================自动评价========================== -->
<bean id=EvalTask" class="com.cmip.quartz.EvalTask"/>
<bean id="EvaDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject">
<ref bean="EvalTask" />
</property>
<property name="concurrent" value="false" />
<property name="targetMethod" value="run" />
</bean>
<bean id="EvalTaskCronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="EvaDetail"></property>
<property name="cronExpression" value="${eval.trigger}"></property>
</bean>