【发布时间】:2019-02-25 15:35:23
【问题描述】:
我有一个带有 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 运行任务时传递类似的参数时,它会失败。例如,在 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 运行它时,它会在 2 个参数之间提供一个空格,而当我通过 Ui 运行它时它不会。不提供此空间会导致问题,因为第一个参数的值变为“SEAT_MIQ_1,last_modified=2018/08/10”,而不仅仅是“SEAT_MIQ_1”,而 last_modified 是另一个参数。
请告诉我如何解决这个问题。谢谢。 :)
【问题讨论】:
-
我当时添加了一个答案。既然您在评论中说:“嘿,非常感谢。我也尝试使用 v1.7.0.M1 并且它有效。我想这是当前版本的错误。非常感谢!”。请采纳答案,见stackoverflow.com/help/someone-answers。
标签: spring spring-batch spring-cloud spring-cloud-dataflow spring-cloud-task