For example you work with Spring Boot + Spring Batch and you need to validate command line arguments as JobParameters
in batch job.
By default Spring Boot uses SimpleCommandLinePropertySource
to resolve Environment
parameters. This PropertySource
implementation recognize --optName[=optValue]
as argument with name optName
and value optValue
.
On the other hand Spring Batch provides DefaultJobParametersConverter
to resolve job parameters. This converter recognize --optName[=optValue]
as non-identifying argument with name -optName
and value optValue
. And if you want to use JobParametersValidator
to validate requred and optional keys in JobParameters
you need to check for -optName
rather then optName
. Or implement custom JobParametersConverter
which will detect these arguments right.
This functionality is pretty common but there are no JIRA features or discussions in mailing lists. This commit is to expose SimpleCommandLineArgsParser
methods and extract fields for --
and =
to implement SimpleCommandLineJobParametersConverter
in Spring Batch project.
I have signed and agree to the terms of the SpringSource Individual Contributor License Agreement.
Comment From: pivotal-issuemaster
@mkanev Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@mkanev Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
Comment From: pivotal-cla
@mkanev Thank you for signing the Contributor License Agreement!
Comment From: snicoll
Thanks for the PR and sorry it took so long to get back to you.
I believe this problem has been fixed as part of https://github.com/spring-projects/spring-boot/issues/19442. If you think otherwise or need more flexibility, I suggest to open a new issue in the Spring Boot project that describes your problem in more details. A small sample that we can run ourselves as a zip attached to the issue would be ideal.