spring 주석 기반 quartz 타이머 설정

1220 단어
spring 통합 quzrtz 를 사용 한 적 이 있 습 니 다. 설정 이 비교적 뚜렷 하고 쉬 웠 지만 xml 파일 의 설정 이 많 지 않 습 니 다. 현재 spring 은 주 해 를 바탕 으로 하 는 quzrtz 설정 을 지원 하여 편리 하 게 사용 할 수 있 고 xml 의 불필요 한 설정 도 면제 합 니 다.
quartz 프로필 을 추가 하고 네 임 스페이스 만 들 기:
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation=http://www.springframework.org/schema/task
        http://www.springframework.org/schema/task/spring-task-3.2.xsd

나머지 는 필요 에 따라 증가한다.
XML 파일 설정:
<task:annotation-driven/>
	<context:annotation-config/>
	<context:component-scan base-package="com.lfex.quzrtz"/>
	<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>

테스트 클래스 테스트 생 성:
@Component
public class QuartzTest {
	
	 @Scheduled(fixedDelay = 1000) 
	    public void test(){
	        System.out.println("        ");
	    } 
}

웹. xml 파일 에 quartz 프로필 추가:
<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:/spring-context.xml,classpath:/quartz-config.xml</param-value>
</context-param>

좋은 웹페이지 즐겨찾기