1.导入相应需要的java包:
2.写一个需要定时被执行的方法:TargetObject.java
3. 修改Spring的配置文件:applicationContext.xml
4.通过加载该配置文件来执行该定时任务:
new ClassPathXmlApplicationContext("applicationContext.xml");
最后的结果是:
2011-06-24 14:51:45run方法执行了
2011-06-24 14:51:45run方法执行了
2011-06-24 14:51:46run方法执行了
2011-06-24 14:51:47run方法执行了
2011-06-24 14:51:48run方法执行了