Announcement Announcement Module
Collapse
No announcement yet.
Autowiring JobParameters instead of individual parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Autowiring JobParameters instead of individual parameters

    I have a tasklet written as thus

    @Component(value = "myTasklet")
    @Scope(value = "step")
    public class MyTasklet implements Tasklet {

    @Value(#{jobParameters['userName']})
    private String userName;

    ...

    }

    I know I can autowire individual parameters, but is there any way to autowire org.springframework.batch.core.JobParameters and thus all the parameters?

  • #2
    You could drop off the qualifier as something like this:

    Code:
    @Value(#{jobParameters})
    private JobParameters params;
    However, I'd recommend not doing this. This ties your artifact more tightly to the underlying Spring Batch framework. If we were to change the implementation of the JobParameters object, this would bleed into your code.

    Comment

    Working...
    X