我可以使用动态属性文件启动Spring Batch应用程序

时间:2016-04-07 21:07:26

标签: java xml spring spring-batch

在Spring Batch中,我可以调用启动上下文:

-classpath -Dprops.file=file:C:/log-inspector-batch/log-inspector-batch/config/daily_report-log.properties %OP% org.springframework.batch.core.launch.support.CommandLineJobRunner launch-context.xml log_inspector_batch_simple

这里的目标是注入属性文件,该文件负责配置应用程序执行的某些扫描日志逻辑。问题是我们不希望编辑任何代码来添加新的扫描位置,我只想通过注入动态属性文件来添加启动应用程序上下文。这可能吗???

最终结果将是许多批次,例如50个,基于属性文件扫描不同的日志位置(试图找到如何知道在调用时使用哪个属性文件的方法)。在我的launch-context.xml中,我有:

<context:property-placeholder location="${props.file}" />

我得到的错误是它无法找到我正在注入的属性文件:

ERROR CommandLineJobRunner:368 - Job Terminated in error: Could not load properties; nested exception is java.io.FileNotFoundException: class path resource [${props.file}.properties] cannot be opened because it does not exist

0 个答案:

没有答案
相关问题