运行 带参数的批处理

Running a batch process with arguments

嗨,我正在尝试 运行 Java 中的批处理 Spring 批处理,我需要将 batchContext.xml 之类的参数传递给我的主参数,但我不知道怎么做,这是我的发射器:

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);
    }

}

}

这是我的工作区

click me

我知道它在这个界面中:

click me

但是正确的变量是什么? 感谢您的帮助

要访问此菜单,您可以: *右键单击启动器 *运行 作为 *运行 配置 *参数

我明白了,在界面中,我的默认路径是 "src-recursos",(这是我的 java 版本的名称,因为它是一个旧项目,在其他版本中将是src / main / java)

我可以作为参数:

"/batch/batchContext.xml" 与引号相同

非常完美,感谢您花时间