[TestSchedule.java]


import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class TestSchedule {

	@Scheduled(cron = "*/5 * * * * *")	// second, minute, hour, day, month, weekday
	public void test() throws InterruptedException{
		System.out.println("-- test");
	}

	@Scheduled(fixedDelay=1000)			// 이전에 실행된 Task의 종료 시간부터
	public void test2() throws InterruptedException{
		Thread.sleep(5000);
		System.out.println("-- test2");
	}

	@Scheduled(fixedRate=1000)			// 이전에 실행된 Task의 시작 시간부터
	public void test3() throws InterruptedException{
		Thread.sleep(5000);
		System.out.println("-- test3");
	}
}

[applicationContext.xml]





	
	
	

[web.xml]





	Board

	
	
		contextConfigLocation
		classpath:config/applicationContext*.xml
	
	
	
		org.springframework.web.context.ContextLoaderListener
	



[build.gradle]


apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.7
version = '1.0'
jar {
    manifest {
        attributes 'Implementation-Title': 'Issue', 'Implementation-Version': version
    }
}

repositories {
    mavenCentral()
}

// 의존성 설정에 사용할 프로퍼티
springVersion = '3.2.0.RELEASE'
slf4jVersion = '1.7.5'
logbackVersion = '1.0.13'

// 메이븐 Central 저장소 사용
repositories {
    mavenCentral()
}

List loggers = [
    "ch.qos.logback:logback-classic:1.0.13",
    "org.slf4j:jcl-over-slf4j:1.7.5",
]

// 의존성 설정
dependencies {
    compile "org.springframework:spring-webmvc:$springVersion"

    compile "commons-lang:commons-lang:2.6"
    compile "commons-httpclient:commons-httpclient:3.1"

	compile "net.sf.json-lib:json-lib:2.2.1:jdk15"
    compile "org.jsoup:jsoup:1.7.3"
    compile "com.taskadapter:redmine-java-api:1.23"

    compile loggers

    testCompile "org.springframework:spring-test:$springVersion"
    testCompile 'junit:junit:4.8.2'
    testCompile 'org.mockito:mockito-core:1.9.0'
}

// commons-logging, log4j, jul 의존성 제거
configurations {
    all.collect { configuration ->
        configuration.exclude group: 'commons-logging', module: 'commons-logging'
        configuration.exclude group: 'log4j', module: 'log4j'
    }
}

uploadArchives {
    repositories {
       flatDir {
           dirs 'repos'
       }
    }
}

+ Recent posts