Get all updates of Java4s

Resource Bundle In Spring: Dynamically Loading The Values For Property Placeholders In XML

Spring »on Feb 11, 2012 { 4 Comments } By Sivateja

Let us see how to load the values into spring configuration file dynamically using ResourceBundle concept

  • Instead of directly placing the values into xml we can load the values at run time for the dataSource properties using ResourceBundle
  • If we want to get the dataSource properties at runtime from ResourceBundle, while configuring the bean into xml we should put bundle keys with expression language into the xml file like…

In ResourceBundle

jdbc.driver = sun.jdbc.odbc.JdbcOdbcDriver

  •  In spring we have pre-defined class given, called PropertyPlaceholderConfigure and this class will read the data from the bundle and it will write the values into the configuration file
  • PropertyPlaceholderConfigure given in
    org.springframework.beans.factory.config.* package


At line number 5, there spring container will read the properties file from bundle.

At line number 6, spring container will write the properties into XML file

Now will see one example..

You Might Also Like

  ::. About the Author .::

- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


4 Responses to “Resource Bundle In Spring: Dynamically Loading The Values For Property Placeholders In XML”
  1. suresh says:

    ur site excellent
    pls provide spring with hibernate

  2. java4s says:


    We are working on spring remaining modules…!
    Will get back to you ASAP.

    Thank you.

  3. Your Explanation on Spring JDBC,as well as explanation on IOC superb,,,,any one can learn spring easily with java4s…

    Thanks Java4s

  4. santhosh says:

    hi , I want dynamically reload the property file without restarting the server. how to implement this in spring.. need this urgent.. can you please me.


By posting your answer, you agree to our comments policy.
What would you like to learn today?
Browse these popular technologies
Spring-Boot-tutorials Hibernate tutorials Spring tutorials Struts tutorials Servlets tutorials Ajax tutorials Log4j tutorials jQuery tutorials Json tutorials Core Java tutorials Web Services tutorials AngularJs tutorials
Most Recent Tutorials
Hibernate_Logo Hibernate Recent Posts Spring_Logo Spring Recent Posts Struts_Logo Struts Recent Posts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.