Enlightensoft's Blog

Helping in your each step

  • Categories

  • Authors

  • Advertisements

How to use Properties File in Spring

Posted by Pankil Patel on August 22, 2010

Style 1: Configure property file to be used in spring xml

# Add new bean entry into your application context.

<bean id=”propertyConfigurer”
<property name=”location”>

# Create new property file into src folder

# Use that property file value

<property name=”user”>
<property name=”password”>

Style 2: Configure property file to be used in spring xml as well as in Java files
Step 1: Do All steps as in Style 1

Step 2: Add one more property called property-override with your “property-placeholder”
location=”classpath:envSettings.properties” />

Step 3: Create one Java Class called “PathConfiguration” and add all properties & it’s setter, getter into this class. After that configure this class in your spring xml file like bellow.

<bean name=”pathConfiguration”

<property name=”attributes”>
<entry key=”pathConf” value-ref=”pathConfiguration” />


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: