title: How to pass parameters from spring boot to spring batch
body: <p>I search a solution to how passing springboot parameters to my spring batch job and then get the value of parameter in my writer. when I load the key in my writer is still null.
  Somebody can help me please ?</p>
  <pre><code>    @GetMapping(&quot;/load/{id}&quot;)
      public BatchStatus load (@PathVariable String id) throws 
      JobExecutionException {
      JobParameters jobParameters = new JobParametersBuilder()
                  .addLong(&quot;time&quot;, System.currentTimeMillis())
                  .addString(&quot;key&quot;, id).toJobParameters();
  
          JobExecution jobExecution = jobLauncher.run(job, jobParameters);
  
          return jobExecution.getStatus();
      }
  </code></pre>
  <p>Here is my Batch code configuration</p>
  <pre><code>@Configuration
  @EnableBatchProcessing
  public class BatchConfig {
  
      @Value(&quot;${path.to.react.file}&quot;)
      private Resource resource;
  
      @Autowired
      public JobBuilderFactory jobBuilderFactory;
  
      @Autowired
      public StepBuilderFactory stepBuilderFactory;
  
      @Autowired
      UserDao userDao;
  
      @Value(&quot;#{jobParameters['key']}&quot;)
      private String pathToFile;
  
      @Bean
      public Job job() {
          return jobBuilderFactory.get(&quot;readCSVFilesJob&quot;)
                  .incrementer(new RunIdIncrementer())
                  .start(step())
                  .build();
      }
  
      @Bean
      public Step step() {
          return stepBuilderFactory.get(&quot;step1&quot;).&lt;UserDTO, 
      UserDTO&gt;chunk(100)
                  .reader(Reader.reader(resource))
                  .processor(new Processor())
                  .writer(new Writer(userDao))
                  .build();
         }
     }
  </code></pre>
  <p>And my Writer</p>
  <pre><code>@StepScope
  public class Writer implements ItemWriter&lt;UserDTO&gt; {
  
  
  private  UserDao userDao;
  
  @Value(&quot;#{jobParameters['key']}&quot;)
  private String key;
  
  public Writer(UserDao userDao) {
      this.userDao = userDao;
  
  }
  
  @Override
  public void write(List&lt;? extends UserDTO&gt; items) throws Exception {
      userDao.writePnoFile(items);
  }
  </code></pre>
  <p>}</p>