2

20分ごとに起動する必要がある単純なトリガーBeanがあります。そのために、プロパティ ファイルで repeatinterval 値を指定しています。しかし、私の仕事は 20 分ごとではなく、1 分ごとに起きています。

サンプル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

これにはどのような理由が考えられますか? 助けてください。前もって感謝します。

4

3 に答える 3

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>
于 2012-10-12T09:40:38.843 に答える
0

今後の参考のために、私は答えています。

私の質問で言及された部分に加えて、以下のコードを追加するのを忘れていました。これは、実際にトリガーするためのものです。

<bean name="nonclusterMode"  class="org.springframework.scheduling.quartz.SchedulerFactoryBean">        
    <property name="triggers">
        <list>              
            <ref bean="propertyLoaderTrigger" />            
        </list>
    </property>
</bean>

現在、期待どおりに機能しています。

于 2013-03-05T11:04:34.280 に答える
0

同じクラス/ジョブ、つまりpropertyLoaderJobに他のトリガーを使用していないことを確認していますか? 同じジョブに関連付けられた cron 式を使用している可能性があります。完全な spring xml ファイルを共有していただければ幸いです。

于 2012-10-12T10:09:10.090 に答える