Win a copy of AWS Security this week in the Cloud/Virtualization 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

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.

Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic