spring boot 整合 quartz时出现

Active Scheduler of name 'DefaultQuartzScheduler' already registered in Quartz SchedulerRepository.
Cannot create a new Spring-managed Scheduler of the same name!

原因是 这个调度器已经被注册过了。

注册的时点和位置是 创建监听器 executorListener 时,会调用quartz.properties文件注册一个scheduler。注册的位置是 QuartzInitializerListener 的 contextInitialized 方法

// 代码做了部分删减package org.quartz.ee.servlet;public class QuartzInitializerListener implements ServletContextListener {public void contextInitialized(ServletContextEvent sce) {this.log.info("Quartz Initializer Servlet loaded, initializing Scheduler...");ServletContext servletContext = sce.getServletContext();try {String configFile = servletContext.getInitParameter("quartz:config-file");   String shutdownPref = servletContext.getInitParameter("quartz:shutdown-on-unload");String shutdownWaitPref = servletContext.getInitParameter("quartz:wait-on-shutdown");StdSchedulerFactory factory = this.getSchedulerFactory(configFile);this.scheduler = factory.getScheduler();String startOnLoad = servletContext.getInitParameter("quartz:start-on-load");int startDelay = 0;String startDelayS = servletContext.getInitParameter("quartz:start-delay-seconds");try {if (startDelayS != null && startDelayS.trim().length() > 0) {startDelay = Integer.parseInt(startDelayS);}} catch (Exception var12) {this.log.error("Cannot parse value of 'start-delay-seconds' to an integer: " + startDelayS + ", defaulting to 5 seconds.");startDelay = 5;}if (startOnLoad != null && !Boolean.valueOf(startOnLoad)) {this.log.info("Scheduler has not been started. Use scheduler.start()");} else if (startDelay <= 0) {this.scheduler.start();this.log.info("Scheduler has been started...");} else {this.scheduler.startDelayed(startDelay);this.log.info("Scheduler will start in " + startDelay + " seconds.");}String factoryKey = servletContext.getInitParameter("quartz:servlet-context-factory-key");servletContext.setAttribute(factoryKey, factory);String servletCtxtKey = servletContext.getInitParameter("quartz:scheduler-context-servlet-context-key");if (servletCtxtKey == null) {servletCtxtKey = servletContext.getInitParameter("scheduler-context-servlet-context-key");}if (servletCtxtKey != null) {this.log.info("Storing the ServletContext in the scheduler context at key: " + servletCtxtKey);this.scheduler.getContext().put(servletCtxtKey, servletContext);}} catch (Exception var13) {this.log.error("Quartz Scheduler failed to initialize: " + var13.toString());var13.printStackTrace();}}
}// 在调用
// this.scheduler = factory.getScheduler(); 时,会读取quartz.properties文件。
// 并注册一个名为 DefaultQuartzScheduler 的调度器。调度器的名字是通过org.quartz.scheduler.instanceName属性配置的。

因此,自定义的quartz配置文件不可以与quartz.properties相同,org.quartz.scheduler.instanceName的值也不能为DefaultQuartzScheduler
修改好以上两处,问题即可解决。
也可以不使用监听器。

Active Scheduler of name ‘DefaultQuartzScheduler‘ already registered in Quartz SchedulerRepository.相关推荐

  1. Quartz的Scheduler初始化源码分析

    2019独角兽企业重金招聘Python工程师标准>>> Quartz的使用:http://donald-draper.iteye.com/blog/2321886  Quartz的S ...

  2. 在MySQL数据库上使用Quartz Scheduler入门

    这是一些简单的步骤,可帮助您使用Groovy在MySQL数据库上完全入门Quartz Scheduler. 以下脚本可让您使用外部文件快速尝试不同的Quartz配置设置. 第一步是使用表设置数据库. ...

  3. 浅谈Scheduler

    转载地址:https://www.cnblogs.com/qlqwjy/p/8721982.html 1.Scheduler工厂模式 所有的Scheduler实例应该由SchedulerFactory ...

  4. 实战Quartz的Scheduler

    一 点睛 1 Scheduler是通过工厂模式创建的. 所有的Scheduler实例由SchedulerFactory来创建. 2 Quartz的三个核心概念 调度器 任务 触发器 3 Schedul ...

  5. java 获取scheduler_Spring Scheduler定时任务 + Quartz

    定时任务几种实现方式 Java自带的java.util.Timer类,这个类允许你调度一个java.util.TimerTask任务,没怎么用过就不说了. Spring3.0以后自带的task,可以将 ...

  6. spring boot application.properties 属性详解

    2019年3月21日17:09:59 英文原版: https://docs.spring.io/spring-boot/docs/current/reference/html/common-appli ...

  7. SpringBoot2.x(三)热部署devtool和配置文件自动注入实战

    参考文档 官方参考文档 如果使用谷歌浏览器,你可以在该页面上通过 ctrl F进行关键字查找以快速检索想查阅的内容. 热部署devtool 按照传统的调试方式,我们每次修改类文件.配置文件之后都需要重 ...

  8. Symbian操作系统中的线程和进程

    在Symbian操作系统中,每个进程都有一个或多个线程.线程是执行的基本单位.一个进程的主线程是在进程启动时生成的. Symbian属于抢占式多任务操作系统,这意味着每个线程都有自己的执行时间,直到系 ...

  9. SpringBoot2.1.0的官网配置文件application.properties(根据需要摘取)

    ============================================================================== SpringBoot2.1.0的官网配置文 ...

最新文章

  1. HTML页面展示遇到问题
  2. 【编译原理】有限自动机NFA-ε到NFA的探索
  3. 密码协议(三)裁决协议和自动执行协议
  4. JavaScript简明教程之快速入门
  5. VTK:图表之ScaleVertices
  6. Laravel 校验规则之字段值唯一性校验
  7. C# 字符,字符串和文本处理。
  8. java jndi tcp_spring配置下通过tomcat的jndi服务连接数据库
  9. (王道408考研数据结构)第四章串-第二节:串的模式匹配算法(朴素和KMP)
  10. gd32 定时器时钟_漫谈LiteOS之开发板-Timer(基于GD32450i-EVAL)
  11. [算法]机器人运动范围
  12. JZOJ 1259. 牛棚安排
  13. 用tensorflow实现线性回归算法
  14. jmeter throughput图表_jmeter生成HTML格式性能测试报告
  15. linux 编译libvlc,libvlc-源码编译流程记录
  16. webflux excel文件上传:java.io.IOException: Unable to read entire header; 0 bytes read; expected 512 byte
  17. OEM和ODM的区别
  18. Zabbix Database error
  19. COMSOL弱形式解微分方程
  20. git 撤销提交 撤销暂存区 取消操作

热门文章

  1. 写一篇与技术无关的文章,如何查询北京住房公积金
  2. 【游戏 AI】7 - AI 引擎
  3. 瞄准500亿元规模 湖北打造国家级大数据产业基地
  4. Win10 下安装及使用ArcGIS 10.X 问题汇总
  5. ethos-专用系统 升级公告!
  6. PDF如何拆分?一个PDF文件怎么拆分成多个
  7. 跨国合作的项目管理中值得注意的一些事情
  8. ××教育Excel数据分析面试题
  9. A-LOAM源码编译运行
  10. 2021最强Python学习教程,从零基础入门到精通