spring boot使用quartz定时器启动报错,但是定时器正常运行
来源:互联网 发布:足球比赛 编排软件 编辑:程序博客网 时间:2024/06/07 11:41
spring boot添加quartz定时器报错但是定时器正常运行
[DEBUG] 2017-11-29 11:28:13,533 org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor - Could not find default TaskScheduler bean
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.scheduling.TaskScheduler' available
检查之后发现
,Spring的定时任务调度器会尝试获取一个注册过的 task scheduler来做任务调度,它会尝试通过BeanFactory.getBean的方法来获取一个注册过的scheduler bean,获取的步骤如下:
1.尝试从配置中找到一个TaskScheduler Bean
2.寻找ScheduledExecutorService Bean
3.使用默认的scheduler
前两步,如果找不到的话,就会以debug的方式抛出异常,分别是:
logger.debug("Could not find default TaskScheduler bean", ex);
logger.debug("Could not find default ScheduledExecutorService bean", ex);
所以,日志中打印出来的两个异常,根本不是什么错误信息,也不会影响定时器的使用,只不过是spring的自己打印的一些信息罢了,不过没搞明白,为什么非要用异常的方式打出来,估计是为了看这清晰点吧。也或者,这里面有一些重要的信息需要提示开发者。具体是什么原因,只能有机会进一步再去了解了。
下面贴上我的定时器代码。仅供记录参考:
package com.tt.pwp.report.quartz;import com.tt.pwp.report.ws.client.request.PlatFormConfig;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.beans.factory.annotation.Configurable;import org.springframework.context.annotation.Configuration;import org.springframework.scheduling.annotation.EnableScheduling;import org.springframework.scheduling.annotation.Scheduled;import org.springframework.stereotype.Component;import java.util.Date;/** * Created by Administrator on 2017/11/24 0024. */@Component@Configurable@EnableSchedulingpublic class ReportDataQuartz { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); @Autowired private PlatFormConfig ymlConfig; @Scheduled(fixedRate = 500000) // 每分5m行一次 public void doReportOneDay() throws Exception { System.out.println("执行调度任务:"+new Date()); }// public void doReportTwoDays() throws Exception {// System.out.println("执行调度任务:"+new Date());// }// public void doReportThereDays() throws Exception {// System.out.println("执行调度任务:"+new Date());// }// public void doReportFourDays() throws Exception {// System.out.println("执行调度任务:"+new Date());// }// public void doReportFiveDays() throws Exception {// System.out.println("执行调度任务:"+new Date());// }// public void doReportSixDays() throws Exception {// System.out.println("执行调度任务:"+new Date());// }// public void doReportOneWeek() throws Exception {// System.out.println("执行调度任务:"+new Date());// }// public void doReportOneMonth() throws Exception {// System.out.println("执行调度任务:"+new Date());// }}
- spring boot使用quartz定时器启动报错,但是定时器正常运行
- Spring quartz 定时器报错
- Spring+Quartz定时器的使用
- spring 中使用Quartz 定时器
- Spring Quartz定时器的使用
- spring定时器(Quartz)的使用
- Spring-Quartz定时器的使用
- Spring Boot定时器如何使用
- spring boot 中使用定时器
- spring boot 中使用定时器
- spring定时器与quartz定时器
- Java定时器,Spring定时器和quartz定时器
- java定时器,Spring定时器和Quartz定时器
- java定时器,Spring定时器和Quartz定时器
- spring中quartz定时器的使用
- 定时器Quartz在Spring中的使用
- Spring 使用 Quartz 任务调度定时器
- spring 框架下使用quartz 定时器
- 第三届滴滴算法大赛开始报名,冠军队就缺你了!
- 【设计模式】命令模式(Command Pattern)
- 连载笔记| k-近邻算法实战笔记(上)
- 从今天起,拒绝再做机器学习困难户
- matlab2010激活问题
- spring boot使用quartz定时器启动报错,但是定时器正常运行
- JVM调优总结 -Xms -Xmx -Xmn -Xss
- 总结一次项目中切换速度的优化
- Java中FTP文件上传下载中文文件乱码问题
- spring boot对json 输入流数据拦截分析处理
- Android Butterknife 8.4.0 使用方法总结
- MindManager 2018计划视图基本操作
- 程序员 30 岁前,该如何规划自己的职业发展?
- Javascript-数组