我遵循了这个例子:https ://spring.io/guides/gs/scheduling-tasks/ 。有用。然后,我将其更改为 scala 代码。我的斯卡拉代码:
@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!!!")
}
}
为什么我的 scala 代码不起作用?谢谢