标签:ide for block XML out ack exp import test
1.spring+task文件配置
1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:task="http://www.springframework.org/schema/task" 5 xmlns:context="http://www.springframework.org/schema/context" 6 xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.2.xsd 7 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 8 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> 9 10 11 <task:annotation-driven/> 12 <context:component-scan base-package="com.task"/> 13 </beans>
2.业务类
1 package com.task; 2 3 import org.springframework.scheduling.annotation.Scheduled; 4 import org.springframework.stereotype.Component; 5 6 @Component 7 public class TestScheduled { 8 9 @Scheduled(cron="0/5 * * * * ? ") //每5秒执行一次 10 public void test(){ 11 for(long i=0;i<1000000000000000000l;i++){ 12 System.out.print((char)i); 13 if(i%15==0){ 14 System.out.println(); 15 } 16 } 17 } 18 }
启动程序就开始跑了
标签:ide for block XML out ack exp import test
原文地址:http://www.cnblogs.com/javaweb2/p/6254039.html