错误1:
配置文件:

    <!-- 任务执行器的线程池 -->
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="5" />
<property name="keepAliveSeconds" value="60" />
<property name="maxPoolSize" value="10" />
<property name="queueCapacity" value="50" />
</bean> <!-- 定时任务的工作Bean -->
<bean id="hourquartzJob" class="com.tasks.HourTaskServiceImpl">
<property name="taskExecutor" ref="taskExecutor" />
</bean> <!-- 定义生成工作对象的工厂,并为工厂设定目标对象targetObject属性、目标对象的工作方法targetMethod属性 -->
<bean id="hourjobDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="hourquartzJob" />
<property name="targetMethod">
<value>synchronizeDb</value>
</property>
<property name="concurrent" value="false" />
</bean> <!-- 任务调度计时器,进行定时设置。CronTriggerBean能进行非常精确的定时设置 -->
<bean id="hourcronQuartz" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="hourjobDetail" ref="hourjobDetail" />
<!-- cron表达式 -->
<property name="cronExpression">
<!-- 0 0 */2 * * ? 每两小时、整点触发 -->
<!-- 0 0/2 * * * ? 每两分钟 -->
<!-- 0/5 * * * * ? 每五秒钟 -->
<!-- 0 15 10 * * ? 每天Y分X点触发 -->
<value>0 */5 * * * ?</value>
</property>
</bean> <!-- 调度任务触发器,启动定时任务-->
<bean autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="hourcronQuartz" />
</list>
</property>
</bean>

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

错误:

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" />

最新文章

  1. IntelliJ IDEA 15,16 win 7 64位安装包以及注册码 百度云盘
  2. Android 卡片计数器
  3. Hibernate uniqueResult方法的使用
  4. 浅谈C++多态性
  5. docker中安装ssh服务
  6. 【BZOJ】1043: [HAOI2008]下落的圆盘(计算几何基础+贪心)
  7. 类名.class, class.forName(), getClass()区别
  8. work_6
  9. MVC-HtmlHelper扩展
  10. MyEclipse整合Git
  11. web - 清除浮动
  12. ListView的操作模式的选择的更详细的解释CHOICE_MODE_MULTIPLE与CHOICE_MODE_MULTIPLE_MODAL
  13. K8S中如何跨namespace 访问服务?为什么ping不通ClusterIP?
  14. uva 11183 Teen Girl Squad
  15. RNA Sequencing
  16. Idea无法运行Maven项目
  17. Git_撤销修改
  18. Oracle 对比两张表不一样 的数据
  19. u-boot.bin生成过程分析
  20. bzoj 2566 calc 拉格朗日插值

热门文章

  1. NOIP提高组题目归类+题解摘要(2008-2017)
  2. 透明数据加密 (TDE)常见问题解答
  3. 洛谷P4548 [CTSC2006]歌唱王国(概率生成函数)
  4. js中闭包和对象相关知识点
  5. CRC循环冗余校验算法
  6. 【关于selenium自动化中,Webdriver的原理以及工作流程】
  7. js 正则常用方法
  8. [BZOJ 5074][Lydsy1710月赛]小B的数字
  9. 评估指标:ROC,AUC,Precision、Recall、F1-score
  10. # js设置键名和键值de坑