使用 UI spring 云数据流中的多个参数启动任务时出错
Error when launching tasks with multiple arguments from UI spring cloud dataflow
我有一个带有 2 个参数的批处理作业。当我在 运行 直接 jar 文件时传递这些参数时,它起作用了。此外,当我通过 spring 云数据流的 shell 传递这些参数时,它起作用了:
dataflow:>task launch --name adv-load --arguments "appnexus_seat=SEAT_MIQ_1 last_modified=2018/08/10"
Launched task 'adv-load'
但是,当我在 运行 任务形成 UI 时传递类似的参数时,它失败了。例如,在 UI 中,我传递了:appnexus_seat & last_modified 作为 2 个键,它们具有与上面相同的值但不同的日期,因此它认为它不是同一个工作。这失败了。
不过我确实设法找到了问题所在。当我通过 shell 运行 任务时,在日志中我得到这个:
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
如果您查看差异,您会发现当我 运行 通过 shell 它在两个参数之间给出 space 而当我 运行它通过 Ui 它没有。不给出此 space 会导致问题,因为第一个参数的值变为 "SEAT_MIQ_1,last_modified=2018/08/10" 而不是 "SEAT_MIQ_1" 而 last_modified 是另一个参数。
请告诉我如何解决这个问题。谢谢。 :)
当您 运行 来自 UI 的任务时,您需要在单独的字段中指定每个参数:
这会正确地将参数传递给您的任务。
我有一个带有 2 个参数的批处理作业。当我在 运行 直接 jar 文件时传递这些参数时,它起作用了。此外,当我通过 spring 云数据流的 shell 传递这些参数时,它起作用了:
dataflow:>task launch --name adv-load --arguments "appnexus_seat=SEAT_MIQ_1 last_modified=2018/08/10"
Launched task 'adv-load'
但是,当我在 运行 任务形成 UI 时传递类似的参数时,它失败了。例如,在 UI 中,我传递了:appnexus_seat & last_modified 作为 2 个键,它们具有与上面相同的值但不同的日期,因此它认为它不是同一个工作。这失败了。
不过我确实设法找到了问题所在。当我通过 shell 运行 任务时,在日志中我得到这个:
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
如果您查看差异,您会发现当我 运行 通过 shell 它在两个参数之间给出 space 而当我 运行它通过 Ui 它没有。不给出此 space 会导致问题,因为第一个参数的值变为 "SEAT_MIQ_1,last_modified=2018/08/10" 而不是 "SEAT_MIQ_1" 而 last_modified 是另一个参数。
请告诉我如何解决这个问题。谢谢。 :)
当您 运行 来自 UI 的任务时,您需要在单独的字段中指定每个参数:
这会正确地将参数传递给您的任务。