凌云兜儿 2016-01-13 08:40 采纳率: 0%
浏览 4753

quartz持久化到数据库

quartz在项目启动时,是不是会根据配置文件自动持久化到数据库,我的配置如下:

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
     <property name="dataSource" ref="dataSource" />
    <property name="configLocation" value="classpath:properties/quartz.properties" />
    <property name="autoStartup" value="true" />
    <property name="applicationContextSchedulerContextKey" value="applicationContext" />
    <property name="startupDelay" value="20" />
    <property name="overwriteExistingJobs" value="true" />
    <property name="triggers">
        <list>
            <!-- 触发器列表 -->
            <ref bean="helloJobTrigger" />
        </list>
    </property>
</bean>

<bean id="helloJobBean" class="com.maidou.job.HelloJob"/>

<!-- 触发器 -->
<bean id="helloJobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
    <property name="jobDetail" ref="helloJobDetail" />
    <property name="cronExpression" value="0/5 * * * * ?" />
    <!--<property name="group" value="group1"/>-->
    <property name="name" value="helloJobTrigger"/>
    <property name="volatility" value="true"/>
</bean>

<!--<bean id="helloJobDetail"-->
        <!--class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">-->
<bean id="helloJobDetail"
        class="com.maidou.factory.MethodInvokingJobDetailFactoryBean">
    <property name="targetObject" ref="helloJobBean" />
    <property name="targetMethod" value="execute" />
    <property name="concurrent" value="false" />
    <property name="durable" value="true"/>
    <property name="volatility" value="true"/>
    <property name="shouldRecover" value="true" />
</bean>

可以连接到数据库,数据库是初始化时建的表,没有添加过数据
在运行时报如下错误:
信息: Loading Quartz config from [class path resource [properties/quartz.properties]]
2016-1-13 16:19:33 com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl info
信息: {dataSource-1} inited
2016-1-13 16:19:34 org.springframework.beans.factory.support.DefaultSingletonBeanRegistry destroySingletons
信息: Destroying singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@a98ce7e: defining beans [org.springframework.scheduling.quartz.SchedulerFactoryBean#0,helloJobBean,helloJobTrigger,helloJobDetail,org.springframework.beans.factory.config.PropertyPlaceholderConfigurer#0,dataSource]; root of factory hierarchy
2016-1-13 16:19:34 com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl info
信息: {dataSource-1} closed
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.scheduling.quartz.SchedulerFactoryBean#0' defined in class path resource [spring-quartz.xml]: Invocation of init method failed; nested exception is org.quartz.JobPersistenceException: Couldn't store trigger 'helloJobTrigger' for 'helloJobDetail' job:The job (DEFAULT.helloJobDetail) referenced by the trigger does not exist. [See nested exception: org.quartz.JobPersistenceException: The job (DEFAULT.helloJobDetail) referenced by the trigger does not exist.]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1420)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:293)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:567)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:83)
at com.maidou.test.main(test.java:13)
Caused by: org.quartz.JobPersistenceException: Couldn't store trigger 'helloJobTrigger' for 'helloJobDetail' job:The job (DEFAULT.helloJobDetail) referenced by the trigger does not exist. [See nested exception: org.quartz.JobPersistenceException: The job (DEFAULT.helloJobDetail) referenced by the trigger does not exist.]
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1270)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$5.execute(JobStoreSupport.java:1176)
at org.quartz.impl.jdbcjobstore.JobStoreSupport$40.execute(JobStoreSupport.java:3716)
at org.quartz.impl.jdbcjobstore.JobStoreCMT.executeInLock(JobStoreCMT.java:242)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.executeInLock(JobStoreSupport.java:3712)
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1172)
at org.quartz.core.QuartzScheduler.scheduleJob(QuartzScheduler.java:870)
at org.quartz.impl.StdScheduler.scheduleJob(StdScheduler.java:254)
at org.springframework.scheduling.quartz.SchedulerAccessor.addTriggerToScheduler(SchedulerAccessor.java:356)
at org.springframework.scheduling.quartz.SchedulerAccessor.registerJobsAndTriggers(SchedulerAccessor.java:287)
at org.springframework.scheduling.quartz.SchedulerFactoryBean.afterPropertiesSet(SchedulerFactoryBean.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1477)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1417)
... 12 more
Caused by: org.quartz.JobPersistenceException: The job (DEFAULT.helloJobDetail) referenced by the trigger does not exist.
at org.quartz.impl.jdbcjobstore.JobStoreSupport.storeTrigger(JobStoreSupport.java:1231)
... 24 more

但是我在数据库添加qrtz_job_details表添加上job后,但是job_data是持久化数据,没有填,启动没有错,但是job不执行,这样的情况请问各位大神如何解决?
  • 写回答

2条回答 默认 最新

  • devmiao 2016-01-13 15:56
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器