有两种方法:
第一种当然你可以把Scheduled写到xml文件中进行配置。
第二种在你的类前面添加
此处讲解第二种写法
第二种在你的类前面添加
@PropertySource("classpath:root/test.props")
然后修改你的@Scheduled(cron="0/5 * * * * ? ") 为 @Scheduled(cron="${jobs.schedule}")
最后在配置文件 test.props中 添加 jobs.schedule = 0/5 * * * * ?
有两种方法:
第一种当然你可以把Scheduled写到xml文件中进行配置。
第二种在你的类前面添加
此处讲解第二种写法
第二种在你的类前面添加
@PropertySource("classpath:root/test.props")
然后修改你的@Scheduled(cron="0/5 * * * * ? ") 为 @Scheduled(cron="${jobs.schedule}")
最后在配置文件 test.props中 添加 jobs.schedule = 0/5 * * * * ?
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。