我使用cron“0 0 9**?”表达式来安排每天早上9点的任务,

t0ybt7op  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(3347)

但问题是这个任务有两次触发,一次在上午9点,另一次在下午2:30,下面是我的代码
@服务公共类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(), "");
    });
}

}

4c8rllxm

4c8rllxm1#

你的亲信应该是这个 0 9 * * * 请参见此以获取解释

相关问题