Spring batch 如何使用带有spring batch CommandLineJobRunner的external application.properties文件

Spring batch 如何使用带有spring batch CommandLineJobRunner的external application.properties文件,spring-batch,Spring Batch,我需要使用application.properties文件在Spring批处理应用程序中定义数据源 当我执行生成的spring boot runnable jar时,资源文件夹中的application.properties被正确使用,并且数据源是根据application.properties中的定义创建的 但是,当使用CommandLineJobRunner类来运行我的作业时,我会得到一个依赖项注入错误,因为spring找不到数据源bean 我尝试将application.propertie

我需要使用application.properties文件在Spring批处理应用程序中定义数据源

当我执行生成的spring boot runnable jar时,资源文件夹中的application.properties被正确使用,并且数据源是根据application.properties中的定义创建的

但是,当使用CommandLineJobRunner类来运行我的作业时,我会得到一个依赖项注入错误,因为spring找不到数据源bean

我尝试将application.properties放在classpath中,与我执行CommandLineJobRunner的文件夹和config文件夹中相同。这些都不起作用。

你可以用这个

<context:property-placeholder location="classpath:/example.jdbc.properties" order="1" system-properties-mode="OVERRIDE"/>


有关详细信息,请参阅

中的第8项。能否显示一些代码和实际错误?您说找不到数据源的事实可能与application.properties无关