Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring 3 how to run a scheduled task with an interval from property file
    text
    copied!<p>I am using Spring 3 to create a scheduled-task.</p> <p>I have to use XML based wiring to configure it, and would like scheduled task to run with an interval that is set in a properties file.</p> <p>Spring Context file:</p> <pre><code>&lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task"&gt; &lt;context:property-placeholder location="classpath:connector.properties"/&gt; &lt;task:scheduler id="connectorScheduler" pool-size="10"/&gt; &lt;task:scheduled-tasks scheduler="connectorScheduler"&gt; &lt;task:scheduled ref="connector" method="checkConnection" fixed-rate="${connector.connectionAttemptDelayMillis}"/&gt; &lt;/task:scheduled-tasks&gt; &lt;bean id="connector" class="com.test.Connector" scope="singleton"&gt; &lt;constructor-arg index="0" value="${connector.user}"/&gt; &lt;constructor-arg index="1" value="${connector.password}"/&gt; &lt;constructor-arg index="2" value="${connector.connectionAttemptDelayMillis}"/&gt; &lt;/bean&gt; &lt;/beans&gt; </code></pre> <p>The problem is that the ${connector.connectionAttemptDelayMillis} is not allowed in the fixed-rate value. This will work fine if i was to put a number in its place, but i need this value to come from a loaded property file.</p> <p>Any help is much appreciated.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload