【发布时间】:2021-02-26 14:56:27
【问题描述】:
我想将 String 的集合作为 step 参数传递。
由于我没有找到构造JobParameter 用于收集的方法,因此我决定将其作为带有逗号分隔值的字符串传递。
我执行作业的代码:
@Autowired
private JobLauncher jobLauncher;
@Autowired
private Job myJob;
public void execute() {
List<String> myCollection = getMyCollection();
jobLauncher.run(myJob, new JobParameters(ImmutableMap.<String, JobParameter> builder()
.put("myCollection", new JobParameter(String.join(",", myCollection)))
.build())
...
}
我将 Step 定义如下:
@Bean
@StepScope
public Step myStep(@Value("#{jobParameters['myCollection']}") String myCollectionString) {
List<String> myCollection = ArrayUtil.asList(lisReferencesString.split(","));
...
}
但是当开始执行时我得到了错误:
org.postgresql.util.PSQLException: ERROR: value too long for type character varying(250)
由于作业参数存储为列值,因此我不能将太长的字符串作为参数传递。
您能建议我如何克服它吗?
【问题讨论】:
标签: java spring spring-batch