quartz-job:与spring 1.x和 spring 2.x的集成

首先引入依赖包:

<dependency>
   <groupId>org.quartz-scheduler</groupId>
   <artifactId>quartz</artifactId>
   <version>2.3.0</version>
</dependency>
<dependency>
   <groupId>org.quartz-scheduler</groupId>
   <artifactId>quartz-jobs</artifactId>
   <version>2.3.0</version>
</dependency>
<dependency>
   <groupId>org.springframework</groupId>
   <artifactId>spring-context-support</artifactId>
</dependency>

接着实现写spirng boot的quartz配置类 QuartzJobConfig ,具体如下:

package com.draco.bootdemo.common.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.draco.bootdemo.common.component.quartzjob.BaseJob;
import com.draco.bootdemo.common.component.quartzjob.BootDemoJobFactory;
import com.draco.bootdemo.model.TaskJobInfo;
import com.draco.bootdemo.service.TaskJobInfoService;
import lombok.extern.slf4j.Slf4j;
import org.quartz.CronScheduleBuilder;
import org.quartz.JobBuilder;
import org.quartz.JobDetail;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.springframework.beans.factory.annotation.Autowire;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;

import javax.sql.DataSource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description 定时任务配置类
 * @Author LongQi
 * @CreateTime 2019/1/11 15:37
 */
@Slf4j
@Configuration
public class QuartzJobConfig {

    public static final List<BaseJob> JOB_LIST = new ArrayList<>();

    @Autowired
    private BootDemoJobFactory bootDemoJobFactory;

    @Autowired
    private DataSource dataSource;

    @Autowired
    private TaskJobInfoService taskInfoService;

    @Bean(destroyMethod = "destroy",autowire = Autowire.NO)
    public SchedulerFactoryBean schedulerFactoryBean(){
        SchedulerFactoryBean factoryBean = new SchedulerFactoryBean();
        initJobAndTrigger(factoryBean);
        factoryBean.setJobFactory(bootDemoJobFactory);
        //factoryBean.setDataSource(dataSource);
        //factoryBean.setConfigLocation(new ClassPathResource("/quartz.properties"));
        factoryBean.setAutoStartup(true);
        factoryBean.setOverwriteExistingJobs(true);
        return factoryBean;
    }

    private void initJobAndTrigger(SchedulerFactoryBean schedulerFactoryBean) {
        QueryWrapper<TaskJobInfo> taskQuery = new QueryWrapper<>();
        taskQuery.in("STATUS",1,2);  //未开始和进行中的job
        taskQuery.orderByAsc("NAME");
        List<TaskJobInfo> tasks = taskInfoService.list(taskQuery);

        Map<String,List<String>> jobCronMap = new HashMap<>();
        for(TaskJobInfo task : tasks){
            if(jobCronMap.keySet().contains(task.getName())){
                jobCronMap.get(task.getName()).add(task.getCronExpression());
            }else{
                List<String> cronList = new ArrayList<>();
                cronList.add(task.getCronExpression());
                jobCronMap.put(task.getName(), cronList);
            }
        }

        JobDetail[] jobDetails = new JobDetail[JOB_LIST.size()];
        Trigger[] triggers = new Trigger[tasks.size()];
        int triggerCount = 0;
        for (int i=0;i<JOB_LIST.size();i++) {
            String jobName = JOB_LIST.get(i).getClass().getName();
            JobDetail jobDetail = JobBuilder.newJob(JOB_LIST.get(i).getClass())
                    .withIdentity(jobName, "jobGroup")
                    .storeDurably(true)
                    .requestRecovery(true)
                    .build();
            List<String> cronList = jobCronMap.get(jobName);
            if(cronList !=null && !cronList.isEmpty()){
                jobDetails[i] = jobDetail;
                for(int j=0;j<cronList.size();j++){
                    Trigger trigger = TriggerBuilder.newTrigger()
                            .withIdentity(jobName + ".Trigger"+j, "triGroup")
                            .forJob(jobName, "jobGroup")
                            .withSchedule(CronScheduleBuilder.cronSchedule(cronList.get(j)))
                            //.withSchedule(CronScheduleBuilder.cronSchedule(cronList.get(j)).withMisfireHandlingInstructionFireAndProceed())
                            .build();
                    triggers[triggerCount] = trigger;
                    triggerCount ++;
                }
            }
        }
        schedulerFactoryBean.setJobDetails(jobDetails);
        schedulerFactoryBean.setTriggers(triggers);
    }

}

接着配置SpringBeanJobFactory,用于spring容器注入job

/**
 * @Description job注入使用
 * @Author LongQi
 * @CreateTime 2019/1/21 12:43
 */
@Component("bootDemoJobFactory")
public class BootDemoJobFactory extends SpringBeanJobFactory {

    @Autowired
    private AutowireCapableBeanFactory capableBeanFactory;

    @Override
    protected Object createJobInstance(TriggerFiredBundle bundle) throws Exception {
        Object jobInstance = super.createJobInstance(bundle);
        capableBeanFactory.autowireBean(jobInstance);
        return jobInstance;
    }
}

job的基本父类如下:

/**
 * @Description job抽象类,自定义job只要继承该类并实现run()即可
 * @Author LongQi
 * @CreateTime 2019/1/12 12:52
 */
@Slf4j
public abstract class BaseJob implements Job{

    @PostConstruct
    public void init(){
        QuartzJobConfig.JOB_LIST.add(this);
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Long beginTime = System.currentTimeMillis();
        log.info(this.getClass().getName()+"开始运行任务...");
        run(jobExecutionContext);
        log.info(this.getClass().getName()+"结束运行任务。总耗时:"+(System.currentTimeMillis()-beginTime)+"ms!");
    }

    /**
     * 实现job运行的业务逻辑
     * @param jobExecutionContext
     */
    public abstract void run(JobExecutionContext jobExecutionContext);
}

具体job类如下:

package com.draco.bootdemo.common.component.quartzjob.job;

import com.draco.bootdemo.common.component.quartzjob.BaseJob;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.stereotype.Component;

/**
 * @Description 定时任务
 * @Author LongQi
 * @CreateTime 2019/1/12 14:43
 */
@Component
public class DemoJob extends BaseJob {

    @Override
    public void run(JobExecutionContext context) {
        System.out.println("执行job,此次对应的cron表达式为:"+context.getTrigger().getKey());
    }
}

写完上面几个类后,数据库里建立如下表:

##quartz - job  业务job表
/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     2019/1/21 20:42:33                           */
/*==============================================================*/


drop table if exists TASK_JOB_INFO;

/*==============================================================*/
/* Table: TASK_JOB_INFO                                         */
/*==============================================================*/
create table TASK_JOB_INFO
(
   ID                   bigint comment '主键ID',
   NAME                 varchar(150) comment 'JOB名称(一般是job的class名称)',
   CRON_EXPRESSION      varchar(50) comment 'CRON表达式',
   TRIGGER_TIME         datetime comment '触发时间',
   STATUS               tinyint comment '状态(1:未开始  2:进行中  3:已结束 )',
   CREATOR              bigint comment '创建人',
   MODIFIER             bigint comment '修改人',
   CREATE_TIME          datetime comment '创建时间',
   MODIFY_TIME          datetime comment '修改时间'
);

alter table TASK_JOB_INFO comment '任务Job表';

最上面的taskInfoService是TASK_JOB_INFO表对应的表接口,用于查询要进行的任务

2025-07-23 09:33:01 2025-07-23 09:33:01.128 -> [main] -> INFO com.fc.V2Application - Starting V2Application v0.0.1-SNAPSHOT using Java 1.8.0_212 on ddad2af35401 with PID 1 (/app.war started by root in /) 2025-07-23 09:33:01 2025-07-23 09:33:01.129 -> [main] -> DEBUG com.fc.V2Application - Running with Spring Boot v2.4.1, Spring v5.3.2 2025-07-23 09:33:01 2025-07-23 09:33:01.129 -> [main] -> INFO com.fc.V2Application - The following profiles are active: dev 2025-07-23 09:33:01 2025-07-23 09:33:01.176 -> [main] -> INFO o.s.b.d.env.DevToolsPropertyDefaultsPostProcessor - For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG' 2025-07-23 09:33:02 2025-07-23 09:33:02.134 -> [main] -> INFO o.s.d.r.config.RepositoryConfigurationDelegate - Multiple Spring Data modules found, entering strict repository configuration mode! 2025-07-23 09:33:02 2025-07-23 09:33:02.136 -> [main] -> INFO o.s.d.r.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data Redis repositories in DEFAULT mode. 2025-07-23 09:33:02 2025-07-23 09:33:02.168 -> [main] -> INFO o.s.d.r.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 20 ms. Found 0 Redis repository interfaces. 2025-07-23 09:33:02 2025-07-23 09:33:02.747 -> [main] -> INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'removeDruidAdConfig' of type [com.fc.v2.common.druid.RemoveDruidAdConfig$$EnhancerBySpringCGLIB$$c48737ab] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-07-23 09:33:02 2025-07-23 09:33:02.765 -> [main] -> INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'druidStatInterceptor' of type [com.alibaba.druid.support.spring.stat.DruidStatInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-07-23 09:33:02 2025-07-23 09:33:02.767 -> [main] -> INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'druidStatPointcut' of type [org.springframework.aop.support.JdkRegexpMethodPointcut] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-07-23 09:33:02 2025-07-23 09:33:02.769 -> [main] -> INFO o.s.c.s.PostProcessorRegistrationDelegate$BeanPostProcessorChecker - Bean 'druidStatAdvisor' of type [org.springframework.aop.support.DefaultPointcutAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2025-07-23 09:33:03 2025-07-23 09:33:03.096 -> [main] -> INFO o.s.boot.web.embedded.tomcat.TomcatWebServer - Tomcat initialized with port(s): 8080 (http) 2025-07-23 09:33:03 2025-07-23 09:33:03.110 -> [main] -> INFO org.apache.coyote.http11.Http11NioProtocol - Initializing ProtocolHandler ["http-nio-8080"] 2025-07-23 09:33:03 2025-07-23 09:33:03.111 -> [main] -> INFO org.apache.catalina.core.StandardService - Starting service [Tomcat] 2025-07-23 09:33:03 2025-07-23 09:33:03.111 -> [main] -> INFO org.apache.catalina.core.StandardEngine - Starting Servlet engine: [Apache Tomcat/9.0.41] 2025-07-23 09:33:04 2025-07-23 09:33:04.184 -> [main] -> INFO o.a.c.core.ContainerBase.[Tomcat].[localhost].[/] - Initializing Spring embedded WebApplicationContext 2025-07-23 09:33:04 2025-07-23 09:33:04.185 -> [main] -> INFO o.s.b.w.s.c.ServletWebServerApplicationContext - Root WebApplicationContext: initialization completed in 3008 ms 2025-07-23 09:33:04 2025-07-23 09:33:04.265 -> [main] -> INFO o.s.boot.web.servlet.RegistrationBean - Filter webStatFilter was not registered (possibly already registered?) 2025-07-23 09:33:04 2025-07-23 09:33:04.298 -> [main] -> DEBUG com.fc.v2.common.conf.PutFilter - Filter 'putFilter' configured for use 2025-07-23 09:33:05 2025-07-23 09:33:05.262 -> [main] -> INFO org.quartz.impl.StdSchedulerFactory - Using default implementation for ThreadExecutor 2025-07-23 09:33:05 2025-07-23 09:33:05.264 -> [main] -> INFO org.quartz.simpl.SimpleThreadPool - Job execution threads will use class loader of thread: main 2025-07-23 09:33:05 2025-07-23 09:33:05.276 -> [main] -> INFO org.quartz.core.SchedulerSignalerImpl - Initialized Scheduler Signaller of type: class org.quartz.core.SchedulerSignalerImpl 2025-07-23 09:33:05 2025-07-23 09:33:05.276 -> [main] -> INFO org.quartz.core.QuartzScheduler - Quartz Scheduler v.2.3.2 created. 2025-07-23 09:33:05 2025-07-23 09:33:05.277 -> [main] -> INFO org.quartz.simpl.RAMJobStore - RAMJobStore initialized. 2025-07-23 09:33:05 2025-07-23 09:33:05.278 -> [main] -> INFO org.quartz.core.QuartzScheduler - Scheduler meta-data: Quartz Scheduler (v2.3.2) 'DefaultQuartzScheduler' with instanceId 'NON_CLUSTERED' 2025-07-23 09:33:05 Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally. 2025-07-23 09:33:05 NOT STARTED. 2025-07-23 09:33:05 Currently in standby mode. 2025-07-23 09:33:05 Number of jobs executed: 0 2025-07-23 09:33:05 Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads. 2025-07-23 09:33:05 Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered. 2025-07-23 09:33:05 2025-07-23 09:33:05 2025-07-23 09:33:05.278 -> [main] -> INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler 'DefaultQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties' 2025-07-23 09:33:05 2025-07-23 09:33:05.278 -> [main] -> INFO org.quartz.impl.StdSchedulerFactory - Quartz scheduler version: 2.3.2 2025-07-23 09:33:05 2025-07-23 09:33:05.478 -> [main] -> INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited 2025-07-23 09:33:05 2025-07-23 09:33:05.723 -> [main] -> DEBUG c.f.v.m.auto.SysQuartzJobMapper.selectByExample - ==> Preparing: select id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status from t_sys_quartz_job 2025-07-23 09:33:05 2025-07-23 09:33:05.941 -> [main] -> DEBUG c.f.v.m.auto.SysQuartzJobMapper.selectByExample - ==> Parameters: 2025-07-23 09:33:06 2025-07-23 09:33:06.005 -> [main] -> WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzSchedulerUtil': Invocation of init method failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 2025-07-23 09:33:06 ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 ### The error may exist in URL [jar:file:/app.war!/WEB-INF/classes!/mybatis/auto/SysQuartzJobMapper.xml] 2025-07-23 09:33:06 ### The error may involve com.fc.v2.mapper.auto.SysQuartzJobMapper.selectByExample-Inline 2025-07-23 09:33:06 ### The error occurred while setting parameters 2025-07-23 09:33:06 ### SQL: select id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status from t_sys_quartz_job 2025-07-23 09:33:06 ### Cause: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 2025-07-23 09:33:06.005 -> [main] -> INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutting down. 2025-07-23 09:33:06 2025-07-23 09:33:06.005 -> [main] -> INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED paused. 2025-07-23 09:33:06 2025-07-23 09:33:06.005 -> [main] -> INFO org.quartz.core.QuartzScheduler - Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED shutdown complete. 2025-07-23 09:33:06 2025-07-23 09:33:06.006 -> [main] -> INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-1} closing ... 2025-07-23 09:33:06 2025-07-23 09:33:06.014 -> [main] -> INFO com.alibaba.druid.pool.DruidDataSource - {dataSource-1} closed 2025-07-23 09:33:06 2025-07-23 09:33:06.016 -> [main] -> INFO org.apache.catalina.core.StandardService - Stopping service [Tomcat] 2025-07-23 09:33:06 2025-07-23 09:33:06.030 -> [main] -> INFO o.s.b.a.l.ConditionEvaluationReportLoggingListener - 2025-07-23 09:33:06 2025-07-23 09:33:06 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2025-07-23 09:33:06 2025-07-23 09:33:06.047 -> [main] -> ERROR org.springframework.boot.SpringApplication - Application run failed 2025-07-23 09:33:06 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'quartzSchedulerUtil': Invocation of init method failed; nested exception is org.springframework.jdbc.BadSqlGrammarException: 2025-07-23 09:33:06 ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 ### The error may exist in URL [jar:file:/app.war!/WEB-INF/classes!/mybatis/auto/SysQuartzJobMapper.xml] 2025-07-23 09:33:06 ### The error may involve com.fc.v2.mapper.auto.SysQuartzJobMapper.selectByExample-Inline 2025-07-23 09:33:06 ### The error occurred while setting parameters 2025-07-23 09:33:06 ### SQL: select id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status from t_sys_quartz_job 2025-07-23 09:33:06 ### Cause: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:429) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1780) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:609) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:531) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) 2025-07-23 09:33:06 at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:944) 2025-07-23 09:33:06 at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:923) 2025-07-23 09:33:06 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:588) 2025-07-23 09:33:06 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:144) 2025-07-23 09:33:06 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:767) 2025-07-23 09:33:06 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) 2025-07-23 09:33:06 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:426) 2025-07-23 09:33:06 at org.springframework.boot.SpringApplication.run(SpringApplication.java:326) 2025-07-23 09:33:06 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309) 2025-07-23 09:33:06 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298) 2025-07-23 09:33:06 at com.fc.V2Application.main(V2Application.java:12) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2025-07-23 09:33:06 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2025-07-23 09:33:06 at java.lang.reflect.Method.invoke(Method.java:498) 2025-07-23 09:33:06 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) 2025-07-23 09:33:06 at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) 2025-07-23 09:33:06 at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) 2025-07-23 09:33:06 at org.springframework.boot.loader.WarLauncher.main(WarLauncher.java:59) 2025-07-23 09:33:06 Caused by: org.springframework.jdbc.BadSqlGrammarException: 2025-07-23 09:33:06 ### Error querying database. Cause: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 ### The error may exist in URL [jar:file:/app.war!/WEB-INF/classes!/mybatis/auto/SysQuartzJobMapper.xml] 2025-07-23 09:33:06 ### The error may involve com.fc.v2.mapper.auto.SysQuartzJobMapper.selectByExample-Inline 2025-07-23 09:33:06 ### The error occurred while setting parameters 2025-07-23 09:33:06 ### SQL: select id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status from t_sys_quartz_job 2025-07-23 09:33:06 ### Cause: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239) 2025-07-23 09:33:06 at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:70) 2025-07-23 09:33:06 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73) 2025-07-23 09:33:06 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:446) 2025-07-23 09:33:06 at com.sun.proxy.$Proxy86.selectList(Unknown Source) 2025-07-23 09:33:06 at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:230) 2025-07-23 09:33:06 at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:139) 2025-07-23 09:33:06 at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:76) 2025-07-23 09:33:06 at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:59) 2025-07-23 09:33:06 at com.sun.proxy.$Proxy114.selectByExample(Unknown Source) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2025-07-23 09:33:06 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2025-07-23 09:33:06 at java.lang.reflect.Method.invoke(Method.java:498) 2025-07-23 09:33:06 at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:344) 2025-07-23 09:33:06 at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198) 2025-07-23 09:33:06 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) 2025-07-23 09:33:06 at com.alibaba.druid.support.spring.stat.DruidStatInterceptor.invoke(DruidStatInterceptor.java:73) 2025-07-23 09:33:06 at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) 2025-07-23 09:33:06 at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:215) 2025-07-23 09:33:06 at com.sun.proxy.$Proxy115.selectByExample(Unknown Source) 2025-07-23 09:33:06 at com.fc.v2.service.SysQuartzJobService.selectByExample(SysQuartzJobService.java:108) 2025-07-23 09:33:06 at com.fc.v2.service.SysQuartzJobService$$FastClassBySpringCGLIB$$8fc47ef9.invoke(<generated>) 2025-07-23 09:33:06 at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) 2025-07-23 09:33:06 at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:687) 2025-07-23 09:33:06 at com.fc.v2.service.SysQuartzJobService$$EnhancerBySpringCGLIB$$b174130e.selectByExample(<generated>) 2025-07-23 09:33:06 at com.fc.v2.common.quartz.QuartzSchedulerUtil.init(QuartzSchedulerUtil.java:42) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2025-07-23 09:33:06 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2025-07-23 09:33:06 at java.lang.reflect.Method.invoke(Method.java:498) 2025-07-23 09:33:06 at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) 2025-07-23 09:33:06 at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) 2025-07-23 09:33:06 at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) 2025-07-23 09:33:06 ... 27 common frames omitted 2025-07-23 09:33:06 Caused by: java.sql.SQLSyntaxErrorException: Table 'springbootv2.t_sys_quartz_job' doesn't exist 2025-07-23 09:33:06 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) 2025-07-23 09:33:06 at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) 2025-07-23 09:33:06 at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) 2025-07-23 09:33:06 at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953) 2025-07-23 09:33:06 at com.mysql.cj.jdbc.ClientPreparedStatement.execute(ClientPreparedStatement.java:370) 2025-07-23 09:33:06 at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3461) 2025-07-23 09:33:06 at com.alibaba.druid.filter.FilterEventAdapter.preparedStatement_execute(FilterEventAdapter.java:440) 2025-07-23 09:33:06 at com.alibaba.druid.filter.FilterChainImpl.preparedStatement_execute(FilterChainImpl.java:3459) 2025-07-23 09:33:06 at com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl.execute(PreparedStatementProxyImpl.java:167) 2025-07-23 09:33:06 at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:497) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2025-07-23 09:33:06 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2025-07-23 09:33:06 at java.lang.reflect.Method.invoke(Method.java:498) 2025-07-23 09:33:06 at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) 2025-07-23 09:33:06 at com.sun.proxy.$Proxy118.execute(Unknown Source) 2025-07-23 09:33:06 at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63) 2025-07-23 09:33:06 at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) 2025-07-23 09:33:06 at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) 2025-07-23 09:33:06 at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:326) 2025-07-23 09:33:06 at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) 2025-07-23 09:33:06 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) 2025-07-23 09:33:06 at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) 2025-07-23 09:33:06 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) 2025-07-23 09:33:06 at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2025-07-23 09:33:06 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 2025-07-23 09:33:06 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 2025-07-23 09:33:06 at java.lang.reflect.Method.invoke(Method.java:498) 2025-07-23 09:33:06 at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) 2025-07-23 09:33:06 ... 57 common frames omitted
最新发布
07-24
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

龙行天下_LXTX

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值