[英]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.