没什么可说的, 今天把以前配置的一个job重新整理了下,用maven管理了。
应该说用Maven的特性更多一些:打成的jar是可运行的, 打成的jar包里包括了运行所依赖的jar。
执行“mvn package”后, 再运行“java -jar .\target\rmn190Proj-jar-with-dependencies.jar”命令。
如下输出:
main started. and current second is: 1
job executed.current second is: 30
job executed.current second is: 35
job executed.current second is: 40
job executed.current second is: 45
job executed.current second is: 50
job executed.current second is: 55
============
关于job运行时间点,applicationContext.xml文件中有如下说明
<!--
1 Seconds (0–59)
2 Minutes (0–59)
3 Hours (0–23)
4 Day of month (1–31)
5 Month (1–12 or JAN–DEC)
6 Day of week (1–7 or SUN–SAT)
7 Year (1970–2099)
-->
<!-- 每隔5秒跑一次,30表示首次执行时等30秒,
实验所得数据如下:
main started. and current second is: 1
job executed.current second is: 30
job executed.current second is: 35
job executed.current second is: 40
job executed.current second is: 45
job executed.current second is: 50
job executed.current second is: 55
job executed.current second is: 30
job executed.current second is: 35
job executed.current second is: 40
-->
<property name="cronExpression" value="30/5 * * * * ?" />
本文详细介绍了如何使用Maven管理并配置一个定时执行的job,包括使用Maven打包为可运行jar包,以及在applicationContext.xml文件中设置定时任务的cron表达式。通过执行命令“mvn package”生成的jar包能够实现每5秒执行一次job,展示了Maven在自动化构建和管理依赖方面的强大能力。
7214

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



