I followed the example: https://spring.io/guides/gs/scheduling-tasks/. it works. Then, I changed it to scala codes. My scala codes:
@Component
class ScheduledConsumer {
private val log = LoggerFactory.getLogger(classOf[ScheduledConsumer])
private val dateFormat = new SimpleDateFormat("HH:mm:ss")
@Scheduled(fixedRate = 50)
def reportCurrentTime(): Unit = {
log.info("The time is now {}!!!", ScheduledConsumer.dateFormat.format(new Date))
println("This is for testing!!!")
}
}
Why my scala codes not work? Thanks