cronTrigger 的配置(使用 opensymphonyquartz)
我有一个网络应用程序,必须每天(比如说每个月的第一天)执行一些操作。
这是一个 GWT 应用程序,分为 4 个项目(如果这很重要),我使用 Maven 添加了这些 jar(更新了我的 pom.xml):
opensymphonyquartz 1.6.3 commons-collections
因为我已经在使用 Spring,所以我遵循了本教程(法语教程),
并将教程中编写的内容添加到我的 application-context.xml 文件中。
在编译时,没有问题,但在运行时,我有这个错误:
com.google.gwt.user.client.rpc.StatusCodeException: Error 500 Error creating bean with name 'schedulerFactory' defined in class path resource [application-context.xml]: Cannot resolve reference to bean 'cronTrigger' while setting bean property 'triggers' with key [0];nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronTrigger' defined in class path resource [application-context.xml]: Error setting property values;nested exception is org.springframework.beans.PropertyBatchUpdateException;nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'cronExpression' threw exception;nested exception is java.text.ParseException: Unexpected end of expression.
它来自哪里?
我的 application-context.xml 的一部分:
<!-- Configuration du crontrigger -->
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref local="exampleJob" />
</property>
<!-- run every day at 6AM -->
<property name="cronExpression" value="0 0 6 * * ?" />
</bean>
<bean id="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="fr.web.utils.ExampleJob" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
I have a web app that has to do something every, let's say first day of every month.
It's a GWT application divided into 4 projects (if that ever matters) and I added these jars using Maven (which updated my pom.xml):
opensymphony quartz 1.6.3
commons-collections
Since I am already using Spring, I followed this tutorial (Tutorial in French)
and added what's written in the tutorial in my application-context.xml file.
At compile time, no problem, but at runtime, I have this error :
com.google.gwt.user.client.rpc.StatusCodeException: Error 500 Error creating bean with name 'schedulerFactory' defined in class path resource [application-context.xml]: Cannot resolve reference to bean 'cronTrigger' while setting bean property 'triggers' with key [0];nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronTrigger' defined in class path resource [application-context.xml]: Error setting property values;nested exception is org.springframework.beans.PropertyBatchUpdateException;nested PropertyAccessExceptions (1) are: PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'cronExpression' threw exception;nested exception is java.text.ParseException: Unexpected end of expression.
Where does it come from ?
A part of my application-context.xml :
<!-- Configuration du crontrigger -->
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="cronTrigger" />
</list>
</property>
</bean>
<bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail">
<ref local="exampleJob" />
</property>
<!-- run every day at 6AM -->
<property name="cronExpression" value="0 0 6 * * ?" />
</bean>
<bean id="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="fr.web.utils.ExampleJob" />
<property name="jobDataAsMap">
<map>
<entry key="timeout" value="5" />
</map>
</property>
</bean>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是您在 Scheduler 的触发器
cronTrigger
中给出了引用,而您尚未在 XML 文件中声明该引用。提供 XML 以获得更详细的答案
更新
您的 cronExpression 似乎无效
0 0 6 * * ?
使其成为0 0 6 * * ?
注意?
之前的最后一个空格Issue is you have given reference in Scheduler's trigger
cronTrigger
which you haven't declare in the XML file.Provide XML for more detailed answer
Update
Your cronExpression isn't seems to be valid
0 0 6 * * ?
make it0 0 6 * * ?
note the last space before?