您好我正在尝试使用Spring批处理在Java中运行批处理,我需要将batchContext.xml像参数传递给我的main,但我不知道它是怎么做的,这是我的启动器:
public final class Launcher {
private static final String LOG_DECORATOR = "****************************************.";
private static final Logger LOG = Logger.getLogger("batch");
private static final Long MIL = 1000L;
private Launcher(){
throw new UnsupportedOperationException();
}
public static void main(String[] args){
LOG.info(LOG_DECORATOR);
LOG.info(" INICIO DEL PROCESO ");
LOG.info(LOG_DECORATOR);
LOG.info("Cargando datos de configuracion");
for(Object object: args){
System.out.println(object);
}
final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(args[0]);
final PropertyFacade property = applicationContext.getBean(PropertyFacade.class);
Assert.notNull(property, "Datos de configuracion no cargados correctamente");
final String entorno = property.property("entorno");
LOG.info("Entorno: ".concat(entorno));
System.setProperty("java.io.tmpdir", property.property("tempFiles"));
final JobLauncher jobLauncher = (JobLauncher) applicationContext.getBean("jobLauncher");
final Job job = (Job) applicationContext.getBean("job");
long tiempoComenzar;
long tiempoTerminar;
tiempoComenzar = System.currentTimeMillis();
try {
final JobExecution execution = jobLauncher.run(job, new JobParameters());
LOG.info("Job Status : " + execution.getStatus());
LOG.info("Job completed");
} catch (JobExecutionAlreadyRunningException e) {
LOG.info("Error Launcher: ".concat(e.toString()));
LOG.error("Exception Launcher",e);
} catch(IllegalArgumentException e){
LOG.info("Error Launcher: ".concat(e.toString()));
LOG.error("Exception Launcher",e);
} catch(JobInstanceAlreadyCompleteException e){
LOG.info("Error Launcher: ".concat(e.toString()));
LOG.error("Exception Launcher",e);
} catch(JobParametersInvalidException e){
LOG.info("Error Launcher: ".concat(e.toString()));
LOG.error("Exception Launcher",e);
} catch(JobRestartException e){
LOG.info("Error Launcher: ".concat(e.toString()));
LOG.error("Exception Launcher",e);
}finally {
((ConfigurableApplicationContext) applicationContext).close();
tiempoTerminar = System.currentTimeMillis();
final long tiempoDedicado = (tiempoTerminar - tiempoComenzar) / MIL;
LOG.info(
"Fin. Tiempo dedicado a la consulta: ".concat(String.valueOf(tiempoDedicado)).concat(" segundos."));
LOG.info(LOG_DECORATOR);
LOG.info(" FIN DEL PROCESO ");
LOG.info(LOG_DECORATOR);
}
}
}
这是我的工作区
我知道它在这个界面中:
但正确的变量是什么? 我感谢任何帮助
要访问此菜单,您可以: *右键单击启动器 *运行As *运行配置 *参数
答案 0 :(得分:0)
我已经知道了,在接口中我的默认路径是“src-recursos”,(这是我的java版本的名称,因为它是其他版本的旧项目将是src / main / java)
我可以说:
“/ batch / batchContext.xml”,带引号
这非常有效,感谢您抽出时间