title: Inject properties into FlatFileItemWriter in Spring batch
body: <p>I need to generate a file called: <code>NEW_NAME_YYYY-MM-DD</code> where <code>YYYY-MM-DD</code> is the current Date. Everything works fine except for when my batch tries to get the propertie <code>tmp.dir</code> it finds nothing and calls the directory <code>null</code> instead. This is the Writer class I am working with :</p>
  
  <pre><code>public class MyFileWriter extends FlatFileItemWriter {
  
     @Value("${tmp.dir}")
     private String tempDir;
  
     public MyFileWriter(){
        super();
        setResource();
     }
  
     public void setResource() {
        SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD");
        String stringDate = sdf.format(new Date());
        String myPath = tempDir + "/NEW_NAME_" + stringDate + ".csv";
        Resource outputFile = new FileSystemResource(myPath);
        this.setResource(outputFile);
     }
  
  }
  </code></pre>
  
  <p>and this is the bean definition placed in <code>applicationContext.xml</code> along with the property-placeholder for the properties file:</p>
  
  <pre><code>&lt;bean id="csvWriter" class="org.conters.writer.MyFileWriter" scope="step"&gt;
      &lt;property name="lineAggregator"&gt;
          &lt;bean class="org.springframework.batch.item.file.transform.DelimitedLineAggregator"&gt;
              &lt;property name="delimiter" value=";" /&gt;
              &lt;property name="fieldExtractor"&gt;
                  &lt;bean class="org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor"&gt;
                      &lt;property name="names" value="ad,customer,total" /&gt;
                  &lt;/bean&gt;
              &lt;/property&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="encoding" value="${csv.encoding}" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>Any idea on why the propertie isn't injected??? and as for the properties file called <code>batch.properties</code> in my case <strong>it is well declared in the applicationcontext</strong>.</p>