Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How can Spring Batch load properties file from external location and not from within the context

Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I need a quick help here. Hopefully someone will be able to help.
I am having a spring batch application which loads the database configuration from a properties file.
It takes the batch properties file from the context through one of the xml as below.

<context:property-placeholder location=""/> // This is mentioned in one of the xml files and I want to load this from an external path

This file is packaged within the JAR file.
But I want the JAr file to read the from the external location which I would specify.

Can anybody tell me how this can be achieved.
Thanks in advance.

Aashish Sawant
Posts: 13
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyways, I figured it out.
This is to those who would want the file to be read using relative path.

<context:property-placeholder location="file:./config/"/>

Create a config folder in the same directory from where you run the app. Place the file in this config folder.

You can also give the absolute path as below.

<context:property-placeholder location="file:d:/config/"/>

But it should be the relative path we should be usually looking for if we want to deploy the code in various environments having different folder structures.

It would give a normal human mental abilities to rival mine. To think it is just a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!