1.创建string配置文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
<!-- 配置定时器 -->
<!-- JobDetail的配置 -->
<bean id="testJobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<!-- 其中altfAirportInfoUtil 为定时方法所在业务类或者工具类或者普通class doRequestDataAuto这个是定时的方法 其他都是默认配置即可-->
<property name="targetObject" ref="altfAirportInfoUtil"/>
<property name="targetMethod" value="doRequestDataAuto"/>
<property name="concurrent" value="false"/>
<!-- 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 -->
</bean>
<!-- Trigger的配置 -->
<bean id="testTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="testJobDetail"/>
<property name="cronExpression" value="0 */3 * * * ?"/>
<!-- 每隔5秒执行一次:*/5 * * * * ? 每隔1分钟执行一次:0 */1 * * * ?
每天23点执行一次:0 0 23 * * ? 每天凌晨1点执行一次:0 0 1 * * ?
每月1号凌晨1点执行一次:0 0 1 1 * ? 每月最后一天23点执行一次:0 0 23 L * ?
每周星期天凌晨1点实行一次:0 0 1 ? * L 在26分、29分、33分执行一次:0 26,29,33 * * * ?
每天的0点、13点、18点、21点都执行一次:0 0 0,13,18,21 * * ? -->
</bean>
<!-- Scheduler的配置 -->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="testTrigger"/>
</list>
</property>
<property name="autoStartup" value="true"/>
</bean>
</beans>
2. string文件添加成功之后,记得再web里边引入
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:altf/config/spring/***.xml
</param-value>
</context-param>
3. 引入完成之后,编译重启项目
4.之前自己的项目出现过一些错误,具体错误代码没有截图,之前的错误原因是我用的string2.x的jar包,后来换成了string3.x的就好使了,当然了,quartz-all-1.8.6.jar这个包需要引入的