1. New Taskutil.java
Package com.proli.util;import org.springframework.stereotype.service;/** * Created by ex_xxx on 2017/3/12. * * @Servicepublic class taskutil {public void TaskOne () { LogUtil.INTERGURATION.debug (" Howareryouok......debug "); LogUtil.INTERGURATION.info ("Howareryouok......info"); LogUtil.CONFIG.info ("This is CONFIG ... info ...") ); LogUtil.CONFIG.debug ("This is CONFIG ... debug ...") ); } public void tasktwo () {LogUtil.INTERGURATION.debug ("Howareryouok......debug"); LogUtil.INTERGURATION.info ("Howareryouok......info"); LogUtil.CONFIG.info ("This is CONFIG ... info ...") ); LogUtil.CONFIG.debug ("This is CONFIG ... debug ...") ); }}
2. New Scheduler-config.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"Xmlns:context="Http://www.springframework.org/schema/context"Xmlns:task="Http://www.springframework.org/schema/task"xsi:schemalocation="http//Www.springframework.org/schema/beanshttp//www.springframework.org/schema/beans/spring-beans-4.1.xsdhttp//Www.springframework.org/schema/contexthttp//www.springframework.org/schema/context/spring-context-4.1.xsdhttp//Www.springframework.org/schema/taskhttp//www.springframework.org/schema/task/spring-task-4.1.xsd "><context:component-scanBase-package="Com.proli.Util"/> <task:scheduler id="TaskScheduler"Pool-size=" -"/> <task:scheduled-tasks scheduler="TaskScheduler"> <!--trigger tasks every half minute--<task:scheduledref="Taskutil"Method="TaskOne"cron="* * * * ?"/> <!--trigger tasks every 20 seconds--<task:scheduledref="Taskutil"Method="Tasktwo"cron="* * * * * ?"/> </task:scheduled-tasks></beans>
3. Introduction of the Scheduler.xml configuration file
I load in the SPRING-MVC
<!--task Scheduled task xml--> <import resource= "Config/scheduler/scheduler-config.xml"/>
Batch processing (timer) SSM Spring-task