<!-- 配置job定时任务类 --> <bean id="triggerCalculateLecturerProfitJob" class="com.itzixi.quartz.job.CalculateLecturerProfitJob"></bean> <!-- 配置jobDetail --> <bean id="triggerCalculateLecturerProfitJobMethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean"> <property name="targetObject"> <ref bean="triggerCalculateLecturerProfitJob"/> </property> <!-- 要执行triggerCalculateLecturerProfitJob的方法的名称 --> <property name="targetMethod"> <value>execute</value> </property> </bean> <!-- 配置定时任务触发器trigger --> <bean id="triggerCalculateLecturerProfitJobFactoryBean" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"> <property name="jobDetail" ref="triggerCalculateLecturerProfitJobMethod"></property> <!-- 用于测试,每分钟跑一次 --> <!-- <property name="cronExpression" value="0 0/1 * * * ?"></property> --> <!-- 每晚凌晨1点跑 --> <property name="cronExpression" value="0 0 1 * * ? *"></property> </bean> <!-- 配置调度工厂 --> <bean id="springJobSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> <property name="triggers"> <list> <ref bean="triggerCalculateLecturerProfitJobFactoryBean"/> </list> </property> </bean>
时间: 2024-10-12 16:50:22