标签: java scheduled-tasks
我正在服务器上运行Java Spring Web应用程序,我需要每晚自动运行一些功能。由于这是一个Web应用程序,因此程序在服务器上以24/7运行。如何安排我的某些功能每晚晚上7点运行?
答案 0 :(得分:1)
您可以使用Spring的@EnableScheduling(在您的main类中)和@Scheduled(在您需要触发的方法上)注释。您可以在@Scheduled内使用cron表达式。
@EnableScheduling
main
@Scheduled
https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/scheduling/annotation/Scheduled.html