quartz框架没问题。

流程:

sping-quartz配置

<?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:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd "> <context:annotation-config/> <task:annotation-driven/> <!-- 业务对象 -->
<bean id="testJobTask" class="com.sunyard.quartz.TestQuartzTask" />
<!-- 自动扫描包 -->
<context:component-scan base-package="com.sunyard.quartz.*" /> <!-- 定时任务start --> <!-- 调度业务 -->
<bean id="jobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="testJobTask" />
<property name="targetMethod" value="execute" />
</bean> <!-- 增加调用的触发器,触发时间 并注入到调度工厂-->
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobDetail" />
<property name="cronExpression" value="0/10 * * * * ? *" />
</bean> <!-- 设置调度工厂 注入触发器-->
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean> <!-- 定时任务end --> </beans>

之后在web.xml中

 <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring-mybatis.xml,
classpath:spring-quartz.xml
</param-value>
</context-param>

测试

/**
* 定时任务--打印测试定时任务是否成功
* @author wang
*
*/
public class TestQuartzTask{
public void execute() {
System.out.println("定时任务已启动!");
}
}

之后发现启动之后输出两行,即任务启动两次。

最终解决:

<Host appBase="" autoDeploy="true" name="localhost" unpackWARs="true">

将appBase置空即可

最新文章

  1. GCD-两个网络请求同步问题
  2. web开发以及分布式开发C/S B/S系统结构
  3. JavaScript Patterns 7.1 Singleton
  4. 配置 nginx server 出现nginx: [emerg] &quot;root&quot; directive is duplicate in /etc/nginx/server/blogs.conf:7
  5. windows多线程详解
  6. 实战案例--Grunt构建Web程序
  7. bzoj1532
  8. final、抽象类、接口、多态、
  9. EffectiveC#7--选择恒定的原子值类型数据
  10. jquery php 百度搜索框智能提示效果
  11. android教学大纲
  12. java学习笔记 --- 面向对象3
  13. 2017上海QCon之旅总结(中)
  14. 转:聚类、K-Means、例子、细节
  15. easyui datagrid 右边框被隐藏
  16. Ubuntu 16.04.3 安装jenkins
  17. flask 学习
  18. Hystrix参数配置
  19. dos 批量重命名 bat
  20. VS2015工具箱不出现ArcGIS Windows Forms怎么办?

热门文章

  1. Elasticsearch Query DSL(查询语言)
  2. React全局浮窗、对话框
  3. Oracle学习笔记(1)
  4. HZNU-ACM寒假集训Day9小结 倍增
  5. HZNU-ACM寒假集训Day2小结 二分答案
  6. part7 vuex实现数据共享
  7. 线程与进程 concurrent.futures模块
  8. AT1983 BBQ Hard 解题报告
  9. 18 12 24 html 表单学习
  10. cat &lt;&lt;EOF&gt; file