Read Properties File In Spring Java

Read Property file in Spring - JAVA

This is a very quick post on how to read properties file in java using the Spring framework. Follow the below mentioned simple steps to achieve reading a property file using Spring:

1. Place the property file in src/main/resources folder.
2. Add the context:property-placeholder tag in your servlet.xml file

<context:property-placeholder location="," />

NOTE: use comma to register multiple properties file (as in above mentioned line of xml)

3. Now, use the annotation @Value(propertyName) in your java class to fetch the property
For instance,

@Value( "${}" )
    private static String fileName1;

The above lines of code will fetch the value of into static variable fileName1.

NOTE: Spring does not process static members. The member has to be an instance field.

This is it. You now know how to read properties file in java using Spring.

See you around.
Share on Google+

About Sujit Horakeri

Sujit Horakeri is a game freak just like any other next door guy you would come across. He is a Web Developer by Profession, Game Developer by Choice.
Connect with him on:


  1. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Online Training Java Online Training

  2. The blog gave me idea to read properties file in spring My sincere thanks for sharing this post Please Continue to share this post
    Java Training in Chennai

  3. Thanks for a wonderful share. Your article has proved your hard work and experience you have got in this field. Brilliant .i love it reading. Assam Ration Card Status

  4. Great Article… I love to read your articles because your writing style is too good, it is very very helpful for all of us and I never get bored while reading your article because...
    Java Training in Marathahalli
    Python Training in Marathahalli