Как исправить проблемы запланированных задач с помощью Spring BootJAVA

Программисты JAVA общаются здесь
Anonymous
Как исправить проблемы запланированных задач с помощью Spring Boot

Сообщение Anonymous »

Моя запланированная задача заключается в следующем
, но приложение не отвечает, когда я использую @scheduled (cron = "0 46 17 * * *") < /code>
, и когда я использую @scheduled (fixdrate = 50000) < /code>, при сохранении информации на mongodb программа дает ошибку < /p>
[ scheduling-1] o.s.s.s.TaskUtils$LoggingErrorHandler : Unexpected error occurred in scheduled task.< /code> < /p>

: An unexpected error occurred during scheduled work.< /code>
java.lang.NullPointerException< /code> < /p>

please help me for fix my cod .


@Scheduled(cron="0 46 17 * * *")
// @Scheduled(fixedRate = 5000)
@RequestMapping("/closeAttendance}")
public void cloceAttendance() {
System.out.println("-1");
AttendanceService attendanceService=new AttendanceService();
Date date=attendanceService.getCurrentDate();
System.out.println("1");
List attendances=arepo.findByDate(date);
if(attendances!=null) {
System.out.println("attendances"+attendances.size());
System.out.println("2");
//
for(Attendance attendance:attendances) {
System.out.println("3");
attendance=attendanceService.closeAttendance(attendance);
System.out.println("4");
System.out.println("attendance"+attendance.getDate()+" "+ attendance.getPerson());
// arepo.save(attendance);

}

}
}


Подробнее здесь: https://stackoverflow.com/questions/558 ... pring-boot

Вернуться в «JAVA»