Spring下配置job

没什么可说的, 今天把以前配置的一个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 * * * * ?" />

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值