博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
spring中使用quartz时注入时出现的错误
阅读量:6431 次
发布时间:2019-06-23

本文共 4302 字,大约阅读时间需要 14 分钟。

错误1:

配置文件:

synchronizeDb
0 */5 * * * ?

错误:

2013-10-23 17:29:19,754] [main] DEBUG - Invoking destroy() on bean with name 'taskExecutor'

[2013-10-23 17:29:19,754] [main] INFO - Shutting down ThreadPoolExecutor 'taskExecutor'
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hourcronQuartz' defined in class path resource [springconfig/spring-quartz-jobs.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'hourjobDetail' of bean class [org.springframework.scheduling.quartz.CronTriggerBean]: Bean property 'hourjobDetail' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1303)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1042)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:539)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:485)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:455)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:170)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:413)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:735)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:369)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:122)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:66)
    at com.main.Controller.main(Controller.java:19)
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'hourjobDetail' of bean class [org.springframework.scheduling.quartz.CronTriggerBean]: Bean property 'hourjobDetail' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:805)
    at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:655)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:78)
    at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:59)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1300)
    ... 15 more
原因:
<property name="hourjobDetail" ref="hourjobDetail" />
初始化org.springframework.scheduling.quartz.CronTriggerBean时需要注入参数,参数值是setter进行的,参数名也必须匹配。
此处的参数名应为jobDetail
更改如下如下:

<property name="jobDetail" ref="hourjobDetail" />

转载于:https://www.cnblogs.com/softidea/p/3384645.html

你可能感兴趣的文章
CSS颜色代码大全
查看>>
LINQ之路10:LINQ to SQL 和 Entity Framework(下)
查看>>
circle area
查看>>
怎么改变按钮的图标
查看>>
当输入流和输出流同时作用一个文件
查看>>
MySQL关于表碎片整理OPTIMIZE TABLE操作
查看>>
FortiGate 0458版本bug
查看>>
后台post注入爆密码
查看>>
Java --- 多线程 面试题
查看>>
OA项目如何成功实施!
查看>>
FindMaxConsecutive.java
查看>>
面试官问:ZooKeeper 一致性协议 ZAB 原理
查看>>
DNS实现域名正解与反解
查看>>
反向教学系列之——Django入门(一)【不需知道web框架】
查看>>
Linux学习-标准输入输出
查看>>
CentOS 7 配置IP
查看>>
文本处理工具grep及正则表达式
查看>>
Intel VT-x处于禁用状态
查看>>
用什么软件可以修改PDF文件,软件的操作方法
查看>>
如何精简企业主数据“裹脚布”
查看>>