请问如何在使用json api执行弹出批处理作业时将文件名作为作业参数传递?
Map<String, String> map = new HashMap<String, String>();
map.put("jobparameters", "filename=" + UPLOAD_LOCATION + uploadedFile.getFileName() + ".csv");
RestTemplate rstTpl = new RestTemplate();
String result = rstTpl.postForObject(url, map, String.class);
从我的工作中访问该文件,例如
<bean id="edivJobFile" class="org.springframework.core.io.FileSystemResource"
scope="step">
<constructor-arg value="#{jobParameters[filename]}" />
</bean>
答案 0 :(得分:0)
我后来发现用于POST的Spring批处理JSON api(启动作业)允许将作业参数作为POST请求参数(http://docs.spring.io/spring-batch-admin/reference/json.html)传递,例如 jobparameters = filename = myfile.csv,batchCode = 001
jobparameters = filename = myfile.csv,batchCode = 001
所以我后来做了:
MultiValueMap<String, String> mvm = new LinkedMultiValueMap<String, String>();
String fileNameParam = "filename=" + UPLOAD_LOCATION + "/" + uploadedFile.getFileName();
String batchCodeParaam = "batchCode=" + uploadedFile.getBatchCode();
String companyCodeParam = "companyCode=" + companyCode;
mvm.add("jobParameters", fileNameParam + "," + batchCodeParaam + "," + companyCodeParam);
RestTemplate rstTpl = new RestTemplate();
String result = rstTpl.postForObject(url, mvm, String.class);
它有效。 @Michael Pralow,spring api由spring batch admin公开,作为监视和启动作业的选项。 感谢