Spring Batch FlatFileItemWriter - How to use stepExecution.jobId to generate file name

前端 未结 2 1892
不知归路
不知归路 2020-12-15 13:32

I have this FileWriter where I\'m trying to append the current Job Id to the filename that is generated.



        
相关标签:
2条回答
  • 2020-12-15 13:39

    The supported names for late-bindig are:

    • #{jobParameters}
    • #{jobExecutionContext}
    • #{stepExecutionContext}

    If jobId is not directly accessible, look this question.

    Also, resource can be injected directly as

    <property name="resource">
      <value>file://${csv.file}_#{jobExecutionContext['jobId']}</value>
    </property>
    

    because the right resource type is created using a converter.

    0 讨论(0)
  • 2020-12-15 13:51

    #{stepExecution.jobExecution.id} or #{stepExecution.jobExecutionId} should work though.

    The StepContext does provide access to the StepExecution for late binding via SpEL expressions.

    0 讨论(0)
提交回复
热议问题