• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Can you please tell me what the PropertyPlaceHolderConfigurer is and its usage with example

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
In Spring configuration file or the xml file where you declare all your beans,you use the PropertyPlaceHolderConfigurer class which belongs to springframework package. Can you please tell me why do we use this class with a real time scenario...
Thanks for your time in advance.
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When you want to externalize some of your configuration in a .properties file. A lot of the times it can be for things like the database.url and database username, because that will be different for each environment you deploy and test on you don't want that information to be put in your Spring xml file. So you can bump it out to a .properties file.

The PropertyPlaceholderConfigurer is a BeanFactoryPostProcess that looks at the configuration that was read in and replace any "${variableName}" with the value for the variableName that is in the .properties file set in the location property of the PropertyPlaceholderConfigurer

so



and your myprops.properties file could look like



I don't remember URLs for datasources but that still shows you how it works.

Now, I hope you didn't have me write all that out just so you could have a question in this forum for the Book giveaway?

Mark
 
Meenakshi Devi
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you so much.
 
reply
    Bookmark Topic Watch Topic
  • New Topic