Java 我可以用动态属性文件启动Spring批处理应用程序吗
在Spring批处理中,我是否能够调用启动上下文:Java 我可以用动态属性文件启动Spring批处理应用程序吗,java,xml,spring,spring-batch,Java,Xml,Spring,Spring Batch,在Spring批处理中,我是否能够调用启动上下文: -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
-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}" />
请分享完整的开始脚本,包括“java…”,因为它对我来说很有用,可能是参数顺序有问题。我发现这个线程的做法不同:将属性文件作为作业参数运行
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