繁体   English   中英

我正在使用这个 cron“0 0 9 * *?” 每天早上9点调度任务的表达式,

[英]I am using this cron "0 0 9 * * ?" expression for scheduling task at morning 9am every day,

但问题是任务触发了两次,一次在早上 9 点,第二次在下午 2:30,下面是我的代码

@Service public class NotificationScheduler {

@Autowired
private UsersService userService;

@Autowired
private SendSMS sendSms;

@Scheduled(cron = "0 0 9 * * ?")
public void sendSmsNotifictaion() {
    DecimalFormat deciFormat = new DecimalFormat(); 
    deciFormat.setMaximumFractionDigits(4);
    List<Users> userList=userService.getAllUserByIsNotSuAcc();
    userList.forEach(obj -> {
        String updatemsg="UPDATE:+Commission+Wallet+balance+for+"+obj.getName()+"+(AGENT+ID+"+obj.getId()+")+on+"+BaseDateUtil.getDateYYYYMMDD(new Date())+"+is+Rs.+"+deciFormat.format(BaseUtil.getDouble(obj.getBalance()))+".+Log+in+to+Spark+OMOB+to+view+and+transfer+balance.+Thank+you+for+your+trust+and+growth+with+us.+-+Spark+Team";
        sendSms.sendSMS(updatemsg, obj.getAgentmobil(), "");
    });
}

}

您的 cron 应该是这个0 9 * * *请参阅cronguru以获取解释

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM