2

I need to use a application.properties file to define a DataSource in a Spring Batch application.

When I execute the generated spring boot runnable jar, the application.properties in the resource folder is used correctly and the DataSource is created accordingly to the definition in application.properties.

But, when a use the CommandLineJobRunner class to run my job I get a dependency injection error because the spring could not find the DataSource bean.

I have tried to put the application.properties in the classpath, in the same folder where I am executing the CommandLineJobRunner and in a config folder. None of that have worked.

Jandisson
  • 380
  • 1
  • 10
  • can you show some code and the actual error? The fact that you say the DataSource could not be find may have nothing to do with application.properties – Ulises Sep 08 '16 at 21:55

1 Answers1

1

You can use this one

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

For detail, please refer item #8 at the link

Nghia Do
  • 2,588
  • 2
  • 17
  • 31