Batch processing (timer) SSM Spring-task

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.