Springboot2 定时任务

java List<String> 转换成带逗号的字符串


使用commons-lang3-3.3.2.jar

 

org.apache.commons.lang3.StringUtils.join(applyNameList, ",");



1、启动类加注解,开启定时任务

@EnableScheduling


2、添加定时任务类

package com.ukefu.mybatis.ps.sms.quartz;

import com.ukefu.mybatis.ps.sms.entity.SendRecord;
import com.ukefu.mybatis.ps.sms.service.SendRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by Admin on 2018/6/7.
 */
@Component
public class QuartzSendMessage {
    @Autowired
    SendRecordService sendRecordService;

    //    每分钟启动
    @Scheduled(cron = "0/10 * * * * ?")
    public void timerToNow(){
        List<SendRecord> sendRecords = sendRecordService.findCronSendRecord();
        if (sendRecords != null && sendRecords.size()>0){
            sendRecordService.cronsend(sendRecords);
        }

    }
}

猜你喜欢

转载自blog.csdn.net/zsj777/article/details/80951763
今日推荐