<!-- 包注入 -->
<context:component-scan base-package="com.gdtopway.basic" ><!-- 包名称 -->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
<!-- 文件注入 -->
<bean id="deleteRubbishAttachmentsJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="attachmentService" /><!-- 文件名称 -->
<property name="targetMethod" value="deleteRubbishAttachments" /><!-- 方法名 -->
<property name="concurrent" value="false" /> <!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
</bean>
<!-- 周一到周日晚上11点30分执行 -->
<bean id="deleteRubbishAttachmentsTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="deleteRubbishAttachmentsJob" />
<property name="cronExpression" value="0 30 11 ? * 1-7" />
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean" autowire="no">
<property name="triggers">
<list>
<ref bean="deleteRubbishAttachmentsTrigger" />
</list>
</property>
</bean>
Spring定时器配置
最新推荐文章于 2020-05-22 09:54:33 发布