首页 > 技术文章 > Spring中定时任务的实现

xushirong 2018-02-26 08:39 原文

package com.yt.project.stockpledge.schedule;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.yt.project.stockpledge.service.SpProjectServies;
//将该类交给spring管理
@Component
public class TimeOutStatus {
    @Autowired
    private SpProjectServies service;
    //spring定时任务详解(@Scheduled注解)
    @Scheduled(cron = "0 0 23 ? * *")
    public void timeOutStatus() {
        //实现的业务
        service.updateStatus();
    }
}

 

推荐阅读