• maven引入所需的jar包:

<dependency>
	<groupId>org.quartz-scheduler</groupId>
	<artifactId>quartz</artifactId>
	<version>2.2.2</version>
</dependency>		
		
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context-support</artifactId>
    <version>4.2.5.RELEASE</version>
</dependency>


  • spring的配置如下:

<!-- 启动触发器的配置开始 -->
<bean id="startQuertz" lazy-init="false" autowire="no"
    class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="triggers">
        <list>
            <ref bean="analyzeMonthPageAccessTrigger" />
        </list>
    </property>
</bean>	
<!-- 启动触发器的配置结束 -->

<!-- 调度的配置开始 -->
<bean id="analyzeMonthPageAccessTrigger"
    class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
    <property name="jobDetail">
        <ref bean="analyzeMonthPageAccessJobDetail" />
    </property>
    <property name="cronExpression">
    	<!-- 每5秒执行一次,调试用 -->
    	<!-- <value>0/5 * * * * ?</value> -->
    	<!-- 每月的1号凌晨1点执行 -->
        <value>0 0 1 1 * ? *</value>
    </property>
</bean>
<!-- 调度的配置结束 -->

<!-- job的配置开始 -->
<bean id="analyzeMonthPageAccessJobDetail"
    class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject">
    	<ref bean="mGPageAccessService"/>
    </property>
    <property name="targetMethod">
        <value>analyzeMonthPageAccess</value>
    </property>
</bean>
<!-- job的配置结束 -->