1、类加注解
@PropertySource(value = {"WEB-INF/props/task.properties"})
2、方法注解
@Scheduled(cron = "${cronceshi}")
3、配置文件(task.properties)
cronceshi=* * * * * ?
文章介绍了在Spring框架中使用@PropertySource注解加载外部属性文件,以及@Scheduled注解实现定时任务的配置,其中cronceshi是配置文件task.properties中的定时表达式。
1、类加注解
@PropertySource(value = {"WEB-INF/props/task.properties"})
2、方法注解
@Scheduled(cron = "${cronceshi}")
3、配置文件(task.properties)
cronceshi=* * * * * ?
4804
2791
3642

被折叠的 条评论
为什么被折叠?