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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

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

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


Hi,

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.

regards,
Ashish
 
Aashish Sawant
Greenhorn
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.

Regards,
Ashish
 
Montana has cold dark nights. Perfect for the heat from incandescent light. Tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic