• 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
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

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="classpath:batch.properties"/> // This is mentioned in one of the xml files and I want to load this from an external path

This batch.properties file is packaged within the JAR file.
But I want the JAr file to read the batch.properties 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/batch.properties"/>

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/batch.properties"/>

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's a pleasure to see superheros taking such an interest in science. And this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!