Announcement Announcement Module
No announcement yet.
Injecting Property Files into Beans Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Injecting Property Files into Beans

    Is there a way to inject all of the properties from a property file into a bean's DI setter (for Properties, in this case, but possibly for Map as well)?

    In particular, I've got a Spring/Hibernate configuration that currently uses placeholders and a PropertyPlaceholderConfigurer that tosses in the properties from a property file.

    This works well as long as every property file has the same set of configuration entries; it works less well when one copy of the file might be for a local database (driver class, url, username, password) and another for a datasource (jndi name).

    I've done a little poking around in the documentation and mailing list and can't find a mechanism for what I want, which would be something like this:

    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <!-- Other Config Here -->
    <property name="hibernateProperties">

  • #2
    Take a look at: PropertyOverrideConfigurer. I think if you used it in combination with autowiring you could 'automagically' wire up your beans.