▶ 사용할 Quartz Scheduler 서비스를 사용하기 위해 Bean 등록을 해줍니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
    <bean name="dummyJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean" 
          p:jobClass="com.gm.crawling.product.controller.MyAbstractJob"
          p:durability="true">
        <property name="jobDataAsMap">
            <map>
                <entry key="HelloJob" value-ref="HelloJob"/>
            </map>
        </property>
    </bean>
    
    <bean name="mailJob" class="org.springframework.scheduling.quartz.JobDetailFactoryBean"
          p:jobClass="com.gm.crawling.product.controller.MailJob"
          p:durability="true">
        <property name="jobDataAsMap">
            <map>
                <entry key="HelloJob" value-ref="HelloJob"/>
            </map>
        </property>
    </bean>
 
    <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"
          p:jobDetail-ref="dummyJob"
          p:startDelay="1000"
          p:cronExpression="0/30 * * * * ?"/>
          
     <bean id="mailTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean"
          p:jobDetail-ref="mailJob"
          p:startDelay="1000"
          p:cronExpression="0/5 * * * * ?"/>
 
    <bean id="schedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
            <list>
                <ref bean="cronTrigger"/>
                <ref bean="mailTrigger"/>
            </list>
        </property>
    </bean
cs


Quartz CronTrigger로 알아보는 Cron 표현식


http://www.jpinup.com/it/2016/01/29/spring-4-quartz-2-scheduler-con-cron-expression/


프로젝트 구성

1. Maven

2. Quartz 2.2.1

3. spring-context-support 4.0.0

4. spring-core 4.2.4

5. spring-tx 4.2.4

6. spring-context 4.2.4




▶ pom.xml 에서 라이브러리 추가.


Archive for required library: 'D:/repository/org/springframework/spring-aop/3.2.8.RELEASE/spring-aop-3.2.8.RELEASE.jar' in project '프로젝트명' cannot be read or is not a valid ZIP file


해결법 : MAVEN 의 로컬 저장소를 지우거나, 에러 메시지에 표시된 폴더를 지움.

프로젝트 우클릭 > MAVEN > Update Project 실행.

+ Recent posts