Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

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.
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic