我有一个带有2个参数的批处理作业。当我在直接运行jar文件时传递这些参数时,它将起作用。另外,当我通过Spring Cloud数据流的外壳传递这些参数时,它会起作用:
dataflow:>task launch --name adv-load --arguments "appnexus_seat=SEAT_MIQ_1 last_modified=2018/08/10"
Launched task 'adv-load'
但是,当我从UI运行任务时传递类似的参数时,它将失败。例如,在用户界面中,我通过了以下操作:appnexus_seat&last_modified作为2个键,它们的值与上述相同,但日期不同,因此它不认为其功能相同。这失败了。
但是,我确实设法找到了问题。当我通过外壳运行任务时,在日志中我得到:
2018-09-21 14:04:50.970 INFO 4035 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: [appnexus_seat=SEAT_MIQ_1, last_modified=2018/08/10, --spring.cloud.task.executionid=5]
2018-09-21 14:04:51.073 INFO 4035 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=advertiserLoadJob]] launched with the following parameters: [{appnexus_seat=SEAT_MIQ_1, -spring.cloud.task.executionid=5, last_modified=2018/08/10}]
2018-09-21 14:04:51.081 INFO 4035 --- [ main] o.s.c.t.b.l.TaskBatchExecutionListener : The job execution id 5 was run within the task execution 5
2018-09-21 14:04:51.116 INFO 4035 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [advertiserLoadStep1]
当我通过Ui运行它时,我得到了:
2018-09-21 14:05:57.417 INFO 4924 --- [ main] o.s.b.a.b.JobLauncherCommandLineRunner : Running default command line with: [appnexus_seat=SEAT_MIQ_1,last_modified=2018/08/10, --spring.cloud.task.executionid=6]
2018-09-21 14:05:57.518 INFO 4924 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : Job: [FlowJob: [name=advertiserLoadJob]] launched with the following parameters: [{appnexus_seat=SEAT_MIQ_1,last_modified=2018/08/10, -spring.cloud.task.executionid=6}]
2018-09-21 14:05:57.528 INFO 4924 --- [ main] o.s.c.t.b.l.TaskBatchExecutionListener : The job execution id 6 was run within the task execution 6
2018-09-21 14:05:57.586 INFO 4924 --- [ main] o.s.batch.core.job.SimpleStepHandler : Executing step: [advertiserLoadStep1]
2018-09-21 14:05:57.653 ERROR 4924 --- [ main] o.s.batch.core.step.AbstractStep : Encountered an error executing step advertiserLoadStep1 in job advertiserLoadJob
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.advertiserLoadTasklet': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.mediaiq.appnexus.load.client.AppnexusRestClient com.mediaiq.appnexus.batch.tasklet.AbstractPageLoadTasklet.appnexusClient; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'JOB' defined in class path resource [com/mediaiq/appnexus/load/config/AppnexusRestClientFactory.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [com.mediaiq.appnexus.value.AppnexusSeat]: : Failed to convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]: no matching editors or conversion strategy found; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.mediaiq.appnexus.value.AppnexusSeat]: no matching editors or conversion strategy found
如果您查看差异,则可以看到,当我通过外壳运行它时,它在2个参数之间留有一个空格,而当我通过Ui运行它时却没有。如果第一个参数的值变为“ SEAT_MIQ_1,last_modified = 2018/08/10”,而不仅仅是“ SEAT_MIQ_1”,而last_modified是另一个参数,则不给该空间会导致问题。
请让我知道如何解决此问题。谢谢。 :)