我有一个简单的触发器bean,应该每隔20分钟触发一次。 为此,我在属性文件中指定了repeatinterval值。但我的工作是每分钟醒来而不是每20分钟醒来。
示例xml
<bean id="propertyLoaderJob"
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="propertyloader" />
<property name="targetMethod" value="propFlagValidator" />
<property name="concurrent" value="false" />
</bean>
<bean id="propertyLoaderTrigger"
class="org.springframework.scheduling.quartz.SimpleTriggerBean">
<property name="jobDetail" ref="propertyLoaderJob" />
<property name="repeatInterval" value="${quartz.scheduler.repeatInterval}" />
<property name="startDelay" value="${quartz.scheduler.startDelay}" />
</bean>
在属性文件中我有这些字段
quartz.scheduler.repeatInterval=1200000
quartz.scheduler.startDelay=1000
这可能是什么原因? 请帮忙。 提前谢谢。
答案 0 :(得分:0)
您是否为此指定了一个属性占位符
使用Context命名空间,
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
. . .
<context:property-placeholder location="quartz.scheduler.properties" />
. . .
</beans>
或 在应用程序上下文中添加PropertyPlaceholderConfigurer bean
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>classpath:quartz.scheduler.properties</value>
</property>
</bean>
答案 1 :(得分:0)
您确定没有为同一个类/作业使用任何其他触发器,即propertyLoaderJob。可能发生了使用cron表达式以及与同一作业相关联的情况。如果你可以共享完整的spring xml文件,那就太好了。
答案 2 :(得分:0)
为了将来的参考,我正在回答。
在我的问题中提到的部分,我忘了添加以下代码。那是为了实际触发它:
<bean name="nonclusterMode" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref bean="propertyLoaderTrigger" />
</list>
</property>
</bean>
现在它按预期工作了。